我喜欢在 UITableView 下面完成一个 UIToolbar,我想使用 UITableViewController 因为它自己设置数据源和委托(delegate)以及其他东西。
由于目前只有 1 个 View ,并且我的数据没有层次结构,因此我不需要类似主题中提出的 UINavigationController。
我没有设法在 XCode 4.2 的 Interface Builder 中的任何位置(场景设计区域或 View 层次结构)将 UIView 或 UIToolbar 拖放到我的 UITableViewController。
因此我的问题是:如何在 Interface Builder 中将 UIView 添加到 UITableViewController?
我确实设法实现了我打算使用带有 UITableView 的 UIViewController 和包含在其 UIView 中的 UIToolbar 来实现的外观。
将 UIViewController 与 UITableView 一起使用会比依赖 UITableViewController 更复杂吗?
感谢您的时间!
最佳答案
我认为这是你真正的问题
Would using an UIViewController with an UITableView be much more involved than relying on the UITableViewController?
答案是否定的,它没有更多的工作。只需将其添加到 View Controller 的 .h
@interface MyViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
然后在 .h 中添加数据源和委托(delegate)函数(您可以复制并粘贴您当前在 TableViewController 中使用的函数)
注意:从 Xcode 4.5.1 开始:“静态 TableView 仅在嵌入 UITableViewController 实例时有效。”
关于ios - IB - 将 UIView 添加到 UITableViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8458682/