iphone - 当我单击 UIButton 时,我试图找出 UITableView 中当前选择了哪些单元格

标签 iphone ios uitableview uibutton

我有 2 个 UITableView。当我单击 UITableView 外部的 UIButton 时,我试图确定每个表格 View 中选择了哪些单元格。

谁有好的方法吗?我会循环遍历单元格来确定当前选择的单元格吗?或者已经有一个方法可以告诉我?

非常感谢!

最佳答案

你可以使用这个方法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

}

查看 UITableViewDelegate 协议(protocol)引用

UITableViewDelege Reference

编辑:当用户在一个表格中选择一行时,您可以使用此方法以及表格和单元格的几个变量来获取它,然后您可以在用户点击您的按钮。

- (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/

相关文章:

ios - MvvmCross 中的 CoreAnimation 和 ObservableCollection

ios - Objective c-只有特定的 UILabel 在 UITableView 中被编辑

iphone - 在 iPhone 应用程序中将 View 另存为照片

ios - 如何删除 UITableViewCell 滑动以删除弹跳

iphone - 更改 Xcode 4 用于属性列表的编辑器?

ios - React Native 排毒记录用户交互测试脚本

ios - 是否可以使用 MDM 或 Apple Configurator 预配置 OneDrive、DropBox 等应用程序?

ios - 通过模态视图 Controller 登录 View Controller

javascript - 检测 iPad/iPhone 电源按钮和 iPad/iPhone 按钮

iphone - UIImagePickerController 给我一个黑色预览