相关疑难解决方法(0)

indexPathForCell从ios7开始返回nil

我的应用程序在ios6.1下正常运行.尝试了ios7模拟器,以下部分不起作用:

EditingCell *cell = (EditingCell*) [[textField superview] superview];
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
NSLog(@"the section is %d and row is %d", indexPath.section, indexPath.row);
NSUInteger section = [indexPath section];
NSUInteger row = [indexPath row];
NSString *rowKey = [[keysForRows objectAtIndex: section] objectAtIndex: row];
Run Code Online (Sandbox Code Playgroud)

总是来:

the section is 0 and row is 0
Run Code Online (Sandbox Code Playgroud)

虽然选择了另一个部分/行.有人知道为什么这在ios7下不起作用?

objective-c uitableview ios ios7

18
推荐指数
2
解决办法
1万
查看次数

Tableview按钮获取index.row

我在tableview单元格中有一个按钮(名为"deleteTemplate"),当按下它时,我应该得到按钮所在单元格的"index.row".任何人都知道如何获取单元格的"index.row" ,当你单击单元格中的按钮?

我目前的按钮代码:

UITableViewCell *clickedCell = (UITableViewCell *)[[sender superview] superview];
NSIndexPath *clickedButtonIndexPath = [self.tableView indexPathForCell:clickedCell];

NSDictionary *dic = [tableData objectAtIndex:clickedButtonIndexPath.row];
Run Code Online (Sandbox Code Playgroud)

但是clickedButtonIndexPath = NULL?:(

这适用于iOS 6.

谢谢!!!

objective-c uitableview ios ios7

2
推荐指数
1
解决办法
3864
查看次数

标签 统计

ios ×2

ios7 ×2

objective-c ×2

uitableview ×2