• 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];

    }

  • 相关阅读:
    leetcode131分割回文串
    leetcode315 计算右侧小于当前元素的个数
    Tensorflow写代码流程&反向传播
    vue脚手架的搭建
    Vue 脱坑记
    简历中的工作经历要怎么写?
    如何制作高水平简历?
    window.location.hash的知识点
    前端面试题小集
    前端面试题
  • 原文地址:https://www.cnblogs.com/yuyu-2012/p/5065601.html
Copyright © 2020-2023  润新知