ios - IB - 将 UIView 添加到 UITableViewController?

标签 ios xcode cocoa-touch interface-builder xcode4.2

我喜欢在 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/

相关文章:

android - Phonegap 数据库加密 : where should I store the password?

objective-c - 带有 SBJSON 的 NSData 或 NSAttributedString

IOS:向后移动两个 View

ios - [NSTaggedPointerString objectAtIndex :]: unrecognized selector sent to instance

ios - 如何在TabBarController中重用系统图标?

objective-c - 呈现强制横向的模态视图 Controller

iphone - 当前模态视图 Controller

ios - 使用 Swift 泛型创建新的 NSManagedObjects

ios - Flutter:应用程序不是 x86_64。运行 lipo -info:,应用程序架构:arm64

iphone - UINavigationController 标题未应用