ios - 如何告诉静态单元格在 Xcode 中打开特定 View ?

标签 ios xcode uitableview

我有一个带有两个静态单元格的 TableView Controller 。单击每个 View 时,应打开一个预定 View 。如果更容易理解的话,每个单元格的行为都应该像选项卡栏中的一个元素一样。我尝试使用推送转场将每个单元格连接到其 View ,但看起来当我这样做时, Storyboard正在设置整个表格的推送。

如何将每个单元格连接到打开的唯一 View ?

(我愿意在常规 View Controller 上使用 2 个按钮(而不是表格)来实现这一点。)

最佳答案

在你的类中采用 UITableViewDelegate 协议(protocol),并实现

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    if ((indexPath.section == customSection) && (indexPath.row == customRow))
    {
        // Your custom action here
    }
}

关于ios - 如何告诉静态单元格在 Xcode 中打开特定 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11317468/

相关文章:

arrays - 在 Swift 中访问 NSDictionary 中的数据

objective-c - UITableViewDataSource 和多线程

ios - UITableView 内容偏移量 -64pt 问题

ios - 使用Xamarin Forms在iOS中显示保存工具栏按钮

ios - 可重用标识符单元与返回单元子类?

ios - 找不到 Plugin.h 文件 : flutter and xcode

ios - Xcode 9 bug : build on device fails with lots of errors, 模拟器运行良好

ios - 控制可能到达非空函数错误 if 语句的末尾

ios - 使用 UINavigationController 的 initWithNavigationBarClass :toolbarClass: 的正确方法

ios - swift:监听 "struct variable"-change 事件?