如何得到自定义UITableViewCell中的按钮所在的cell的indexPath.row
来源:互联网 发布:晨曦软件支持什么系统 编辑:程序博客网 时间:2024/06/06 02:56
在iOS7下面已经无效,因为iOS7的层级关系发生变化
UITableViewCell->UITableViewCellScrollView->UITableViewCellContentView->Your custom view
下面有2种方法解决这个问题
-(void) visitButtonClicked:(UIButton *)sender
{
// 第一种,兼容所有的版本
UIView *superView = sender.superview;
UITableViewCell *foundSuperView = nil;
while (nil != superView && nil == foundSuperView) {
if ([superView isKindOfClass:[UITableViewCell class]]) {
foundSuperView = (UITableViewCell *)superView;
} else {
superView = superView.superview;
}
}
NSLog(@"founda = %d", [_tableView indexPathForCell:foundSuperView].row);
// 第2种,不兼容iOS7以下
UITableViewCell *cell = (UITableViewCell *)[[[sender superview] superview] superview];
NSLog(@"foundb = %d", [_tableView indexPathForCell:cell].row);
}
- 如何得到自定义UITableViewCell中的按钮所在的cell的indexPath.row
- 如何得到自定义UITableViewCell中的按钮所在的cell的indexPath.row
- 得到自定义UITableViewCell中的按钮所在的cell的indexPath.row
- 获取UITableViewCell中的按钮所在的cell的indexPath.row
- 如何得到自定义UITableViewCell所在的cell的indexPath
- 如何得到自定义UITableViewCell中的按钮所在的cell
- 自定义UITableViewCell中获取按钮所在Cell的indexPath
- iOS中如何通过点击UITableViewCell中的Button来获取当前Cell的indexPath
- 自定义cell中有一个button按钮,按下按钮的同时如何获得该按钮所在的行的row值
- 自定义cell中有一个button按钮,按下按钮的同时如何获得该按钮所在的行的row值
- 通过自定义cell添加的button确定其所在cell的indexPath
- UITableView获取cell的indexPath.row值(多种方式)
- iOS点击Cell中的按钮时,取所在的Cell
- iOS 获取控件所在cell的indexPath值
- UITableView获取cell的row值(解决自定义cell里的button通过点击无法获得cell的indexpath的问题)
- UITableView获取cell的row值(解决自定义cell里的button通过点击无法获得cell的indexpath的问题
- UITableView获取cell的row值(解决自定义cell里的button通过点击无法获得cell的indexpath的问题)
- 自定义Cell访问不了自己的set方法,并且对象初始化产生的不是自定义的类型(cell.contact = self.contacts[indexPath.row])
- A. Game With Sticks
- 一步一步搭建GTK-DFB开发环境
- 发送邮件
- hd 2502 月之数
- 不要做一个浮躁的程序员
- 如何得到自定义UITableViewCell中的按钮所在的cell的indexPath.row
- 正则 - 单词边界 /b
- Oracle数据库的安全策略
- vc++防止多次运行
- C 结构体内存对齐原则
- 收集的ORACLE函数大全
- linux中export用法
- vc++实现文件关联
- 关于js跳转的总结