根据点击头像的手势获取自定义Cell 的属性, UITableViewCell, 头像, iOS

4 篇文章 0 订阅
3 篇文章 0 订阅

//cell.otherID 是自定义 cell 属性


- (void)headImageViewClick:(UITapGestureRecognizer *)tap

{

//1, 通过获取所点击 cell 的属性获取 id 这种最靠谱

   MsgCell *cell = (MsgCell *) [[tap.view.superviewsuperview]superview];

   [self creatUserDetailViewWithID:cell.otherID];

//2, 通过 tap 手势获取 tag 获取, 但是tag 的 int 长度限制, 字段增加的话就不能用了

// cell.headImageView.tag = [cell.otherID integerValue];

//    [self creatUserDetailViewWithID:[NSString stringWithFormat:@"%d",tap.view.tag]];



}


使用 lldb 工具打印: 


1, tap.view获取当前点击的cell的详情

(lldb) po tap.view

<UIImageView: 0xbf1d140; frame = (10 30; 40 40); clipsToBounds = YES; opaque = NO; gestureRecognizers = <NSArray: 0xbf1d360>; layer = <CALayer: 0xbf1d1c0>>


2,  tap.view.superview : 再次获取到的是 cellContentView

(lldb) po tap.view.superview

<UITableViewCellContentView: 0xbf1cc90; frame = (0 0; 320 378); gestureRecognizers = <NSArray: 0xbf1cea0>; layer = <CALayer: 0xbf1cd00>>


3,(lldb) po [tap.view.superview superview] : 

<UITableViewCellScrollView: 0xbf1c820; frame = (0 0; 320 378); autoresize = W+H; gestureRecognizers = <NSArray: 0xbf1caa0>; layer = <CALayer: 0xbf1c9f0>; contentOffset: {0, 0}>


4, (lldb) po [[tap.view.superview superview] superview]  这样才能取出 cell 的属性

<MsgCell: 0xbf1c610; baseClass = UITableViewCell; frame = (0 602; 320 378); autoresize = W; layer = <CALayer: 0xbf1c7f0>>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值