我有 2 个 UITableView
。当我单击 UITableView
外部的 UIButton
时,我试图确定每个表格 View 中选择了哪些单元格。
谁有好的方法吗?我会循环遍历单元格来确定当前选择的单元格吗?或者已经有一个方法可以告诉我?
非常感谢!
最佳答案
你可以使用这个方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
查看 UITableViewDelegate 协议(protocol)引用
编辑:当用户在一个表格中选择一行时,您可以使用此方法以及表格和单元格的几个变量来获取它,然后您可以在用户点击您的按钮。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
thisIsMyTable = tableView;
thisIsTheSelectedRow = indexPath.row;
}
- (void)buttonTapped {
// Do what you need
}
关于iphone - 当我单击 UIButton 时,我试图找出 UITableView 中当前选择了哪些单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8932125/