[iOS]获取自定义button所在的行数(TableViewCell)
来源:互联网 发布:floyd算法输出路径 编辑:程序博客网 时间:2024/05/22 14:07
在自定义的 cell 上面放了一个 button, 除了通过 cell.btn.tag 值获取cell的行数之外,另一种方便可行的方式。
[cell.button addTarget:self action:@selector(cellButtonClicked:event:) forControlEvents:UIControlEventTouchUpInside];// 点击事件- (void)cellButtonClicked:(id)sender event:(id)event { NSSet * touches =[event allTouches]; UITouch * touch =[touches anyObject]; CGPoint currentTouchPosition = [touch locationInView:_tableView]; NSIndexPath * indexPath =[_tableView indexPathForRowAtPoint:currentTouchPosition]; if(indexPath!= nil) { // 代码区 }}
原文链接:http://www.jianshu.com/p/daeb20bc486b
iOS中如何通过点击UITableViewCell中的Button来获取当前Cell的indexPath
- (void) btnOnClickTouched:(UIButton *)aButton{myTableViewCell* myCell = (myTableViewCell *)[aButton superView]; //表示Button添加在了Cell中。//如果将Button添加在myCell.contentView 中,//myCell = (myTableViewCell *)[[aButton superView] superView];
indexPath cellPath = [self.tableView indexPathForCell:myCell]; NSIntage i = cellPath.row; //这个就是cell的indexPath.row;
}
原文链接:http://www.jianshu.com/p/daeb20bc486b
{
myTableViewCell* myCell = (myTableViewCell *)[aButton superView]; //表示Button添加在了Cell中。
//如果将Button添加在myCell.contentView 中,
//myCell = (myTableViewCell *)[[aButton superView] superView];
indexPath cellPath = [self.tableView indexPathForCell:myCell];
NSIntage i = cellPath.row; //这个就是cell的indexPath.row;
}
0 0
- [iOS]获取自定义button所在的行数(TableViewCell)
- 通过button获取所在的tableViewCell
- 【iOS】使用Xib自定义tableViewCell 获取数据
- iOS 如何获取点击的是哪个tableViewCell上的Button按钮?
- jquery获取当前对象所在的行数
- ios——自定义tableviewcell左滑button
- 自定义TableViewCell上的按钮-找到cell行数
- 在TableViewCell里的按钮事件中 获取当前Cell行数(简单做法)
- iOS 自定义子视图获取所在的父控制器
- ios 自定义tableviewcell
- iOS 自定义tableViewcell
- ios 自定义tableViewcell,UITableViewCell
- iOS 自定义TableViewCell封装
- QTableWidget获取选中的内容及所在行数
- QTableWidget获取选中的内容及所在行数
- 获取UItableView中button所在的section和row
- iOS自定义形状的Button
- 自定义TableViewCell的使用方法
- OpenGL入门学习
- java.sql.SQLException: Incorrect string value:
- .net设置用户登录CACHE过期时间
- getsingleresult 为空报错 javax.persistence.NoResultException: No entity found for query
- 自己关于java界面布局的一点心得
- [iOS]获取自定义button所在的行数(TableViewCell)
- mount: unknown filesystem type 'LVM2_member' 解决
- 从 aar 到 Jcenter 看这篇就够了
- 项目文件包含 ToolsVersion="12.0" 设置,而此版本的 MSBuild 不支持该工具版本
- eclipse报eclipse unhandled event loop exception permGen space的解决办法。
- package.json文件中dependencies和devDependencies的区别
- unity-添加编译宏及设置
- Hexo+Github搭建个人博客
- [CSS]CSS浮动float详解(一):标准文档流