我目前正在开发一个 iOS 项目,我对它很陌生。
我的问题描述:我制作了自己的 TableView(包含 UITableView 的 UITableViewController 的派生)。不幸的是,从未调用过“didSelectRowAtIndexPath”方法。我仍然可以滚动 TableView - 我只是无法选择一行!
我的项目描述(-结构):
MyAppDelegate
- 包含MyWindow
MyWindow
- 用途MyRootViewController
MyRootViewController
- 包含MyFirstViewController
MyRootViewController
- 包含MySecondViewController
MyFirstViewController
- 仅包含一个视图和一些按钮和标签作为起始视图。MyFirstViewController
- 实现ViewMediator
MySecondViewController
- 包含MyTableViewController
MySecondViewController
- 实现ViewMediator
ViewMediator
- 让视图在不知道彼此的情况下进行通信的协议MyTableViewController
- 源自于UITableViewController
MyTableViewController
- 包含一个UITableView
(在构造函数中制作)MyTableViewController
- 覆盖cellForRowAtIndexPath
(这有效,因此显示了元素)MyTableViewController
- 覆盖didSelectRowAtIndexPath
(从不调用)MyTableViewController
- 包含MyTableViewModel
MyTableViewModel
- 只是一个类来读取文件并将数据加载到TableView
我已经尝试过的:
- 3.1 手动将“MyTableViewController”设置为包含 UITableView 的委托 - 即使这应该自动完成。
- 3.2 在“MyTableViewController”之外制作 UITableView,然后将其设置为“MyTableViewController.view”和/或“MyTableViewController.tableView”。
- 3.3 我在UITableView中手动启用了UserInteraction。认为这不是真正的问题,因为滚动工作正常。
有趣的事实:它以前工作过,我只是对 ViewControllers 的通信添加了一些小改动。之前它们是直接通信(单向),现在它们通过中介(双向)进行通信——众所周知的中介模式。这不应该影响视图及其控制器,对吧?