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];
}
//定义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开发之int,NSInteger,NSUInteger,NSNumber的使用
- requirejs的简要用法
- [to do list][PCB][questions]and[plan]
- LeetCode "Shortest Distance from All Buildings"
- Leetcode: Count Univalue Subtrees
- [leetcode] 304. Range Sum Query 2D - Immutable 解题报告
- [leetcode] 303. Range Sum Query - Immutable 解题报告
- Divide and Conquer:Cable Master(POJ 1064)
- Team Queue UVA540
- java中ProcessBuilder
- js实现C#的StringBuilder效果完整实例
- Divide and Conquer:Monthly Expense(POJ 3273)
- Request的getParameter和getAttribute方法的区别
- request.getScheme() 使用方法
- JavaSE的UI界面编程
- CALayer 花瓣飘落 转场动画-CATransation 动画组 UIView动画封装
- iOS - UIImageView
- iOS- UIProgressView
- UI相关基础知识
- BlockQueue使用之简单应用