IOS UILabel用UITapGestureRecognizer实现点击事件


     点击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];

}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM