首页 > 移动平台 > 详细

IOS UILabel用UITapGestureRecognizer实现点击事件

时间:2015-12-22 10:24:21      阅读:297      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!