码迷,mamicode.com
首页 > 移动开发 > 详细

IOS UILabel用UITapGestureRecognizer实现点击事件

时间:2015-12-22 10:24:24      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

     点击UILabel跳转页面:

     //定义UILabel

    @property (weak, nonatomic) IBOutlet UILabel *nameLabel;

 

    用UITapGestureRecognizer手势触碰实现UILabel的点击事件

    UITapGestureRecognizer *tapName = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchHeaderImageView:)];

    self.nameLabel.userInteractionEnabled = YES;

    [self.nameLabel addGestureRecognizer:tapName];

    

   

- (void)touchHeaderImageView:(UITapGestureRecognizer *)gesture

{

    if (self.delegate && [self.delegate respondsToSelector:@selector(touchPersonalMoment:)])

    {

        [self.delegate touchPersonalMoment: self.commentTable.createUserId];

    }

}

 

 

   

- (void)touchPersonalMoment:(NSString *)friendId

{

    FriendDetailViewController *viewController = [[FriendDetailViewController alloc] initWithNibName:@"FriendDetailViewController" bundle: nil];

    viewController.hidesBottomBarWhenPushed = YES;

    viewController.friendId = friendId;

    [self.navigationController pushViewController: viewController animated: YES];

}

 

IOS UILabel用UITapGestureRecognizer实现点击事件

标签:

原文地址:http://www.cnblogs.com/yuyu-2012/p/5065601.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!