UITableView获取cell的row值
2015-06-14 19:04
375 查看
在tableview 中,有N个Section,以及N个row,每个中都添加了button,以前的做法是使用tag,后面发现不行。这里有一个新的解决办法。
UITableViewCell *buttonCell = (UITableViewCell *)sender.superview.superview.superview;
NSUInteger section = [[_tableViewDishesindexPathForCell:buttonCell]section];
NSUInteger row = [[_tableViewDishesindexPathForCell:buttonCell]row];
注意:这里是3个superview,第一个是contentView,第二个superview是自己自定义的cell,第三个superview是UITableView的cell。如果不是自定义的cell,那就只要两个superview。
UITableViewCell *buttonCell = (UITableViewCell *)sender.superview.superview.superview;
NSUInteger section = [[_tableViewDishesindexPathForCell:buttonCell]section];
NSUInteger row = [[_tableViewDishesindexPathForCell:buttonCell]row];
注意:这里是3个superview,第一个是contentView,第二个superview是自己自定义的cell,第三个superview是UITableView的cell。如果不是自定义的cell,那就只要两个superview。
相关文章推荐
- [LeetCode] Implement Stack using Queues
- UIActionSheet学习
- 线程安全的BlockingQueue
- iOS程序的启动过程-UIWindow
- loadrunner生成随机uuid的方法
- 黑马程序员——GUI1:上篇
- RequestDispatcher跳转后的乱码问题
- 使用 UICollectionView 实现网格化视图效果
- The project was not built since its build path is incomplete. Cannot fin
- 对于dequeueReusableCellWithIdentifier:的理解
- UIImage 读取图片内存优化
- Atitit.ui控件---下拉菜单选择控件的实现select html
- Atitit.ui控件---下拉菜单选择控件的实现select html
- Qt 5.5 beta - Qt Quick Extras - CircularGauge
- AsyncDisplayKit -- ( facebook/新浪微博 ) 优化UI性能
- Unique Binary Search Trees-LeetCode
- poj2284 That Nice Euler Circuit(欧拉定理+枚举)
- How To Use Coordinates To Extract Sequences In Fasta File
- Leetcode: Implement Stack using Queues
- Android ActivityThread(主线程或UI线程)简介