通过点击cell上的Button获取cell在屏幕的位置

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

ShopViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"shopCell" forIndexPath:indexPath];

if (!cell) {

cell = [[ShopViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"shopCell"];

}

AddButtonFarme=cell.AddButton.frame;

[cell.AddButton addTarget:self action:@selector(btnTwoClicked:) forControlEvents:UIControlEventTouchUpInside];

cell.AddButton.tag=500+indexPath.section;

cell.tag=400+indexPath.section;

NSLog(@"cell===%ld",cell.tag);

NSLog(@"button===%ld",cell.AddButton.tag);

cell.model = _dataArray[_key][indexPath.section];

cell.selectionStyle = UITableViewCellSelectionStyleNone;

return cell;

}

-(void)btnTwoClicked:(UIButton *)btn

{

ShopViewCell *cellll=[self.view viewWithTag:btn.tag-100];

NSIndexPath *indexPath = [_rightView indexPathForCell:cellll];

//获取cell在屏幕中位置

CGRect rectInTableView = [_rightView rectForRowAtIndexPath:indexPath];//cell在tabview的尺寸

CGRect rect = [_rightView convertRect:rectInTableView toView:[_rightView superview]];

cellFrame=rect;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 概述在iOS开发中UITableView可以说是使用最广泛的控件,我们平时使用的软件中到处都可以看到它的影子,类似...
    liudhkk阅读 9,121评论 3 38
  • *7月8日上午 N:Block :跟一个函数块差不多,会对里面所有的内容的引用计数+1,想要解决就用__block...
    炙冰阅读 2,590评论 1 14
  • 版权声明:未经本人允许,禁止转载. 1. TableView初始化 1.UITableView有两种风格:UITa...
    萧雪痕阅读 2,925评论 2 10
  • 伊川王利珍坚持原创分享第313天 问题的界定往往决定了什么才是问题。根据个人的价值和信念,不同的人在同一情况下的经...
    宛如初夏阅读 152评论 0 1
  • 你想当怎样的妈妈? 我想做个酷酷的妈妈耶~ 比如... 。。。 在教育孩子的这条修行之路上 每一个节点就像一个个的...
    辣妈一条阅读 291评论 0 0