美文网首页iOS技术
通过点击cell上的Button获取cell在屏幕的位置

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

作者: HI宏宇 | 来源:发表于2016-06-03 17:54 被阅读1172次

- (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;

相关文章

网友评论

    本文标题:通过点击cell上的Button获取cell在屏幕的位置

    本文链接:https://www.haomeiwen.com/subject/wbmnkttx.html