您的位置:首页 > 产品设计 > UI/UE

IOS UILabel用UITapGestureRecognizer实现点击事件

2015-12-22 09:35 489 查看
点击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];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: