简体   繁体   English

IB - 将UIView添加到UITableViewController?

[英]IB - add UIView to UITableViewController?

I like to accomplish an UIToolbar below an UITableView and I wanted to use the UITableViewController because it sets up the data source and delegate and other stuff on its own. 我喜欢在UITableView下面完成一个UIToolbar,我想使用UITableViewController,因为它自己设置了数据源和委托以及其他东西。

I don't need an UINavigationController as has been proposed in similar topics due to only having 1 view currently and my data is without a hierarchy. 由于目前只有1个视图且我的数据没有层次结构,因此我不需要类似主题中提出的UINavigationController。

I didn't manage to drag and drop an UIView or UIToolbar to my UITableViewController at any place (scene design area or view hierarchy) in Interface Builder of XCode 4.2. 我没有设法在XCode 4.2的Interface Builder中的任何地方(场景设计区域或视图层次结构)将UIView或UIToolbar拖放到我的UITableViewController。

Thus my question: How to add an UIView to an UITableViewController in Interface Builder? 因此我的问题:如何在Interface Builder中向UITableViewController添加UIView?

I did manage to achieve the look I intend to accomplish using an UIViewController with an UITableView and an UIToolbar contained in its UIView. 我确实设法使用UIViewController和UIView中包含的UIToolbar来实现我想要完成的外观。

Would using an UIViewController with an UITableView be much more involved than relying on the UITableViewController? 使用带有UITableView的UIViewController比依赖UITableViewController要多得多吗?

Thank you for your time! 感谢您的时间!

I think this is your real question 我认为这是你真正的问题

Would using an UIViewController with an UITableView be much more involved than relying on the UITableViewController? 使用带有UITableView的UIViewController比依赖UITableViewController要多得多吗?

The answer is no, its not much more work. 答案是否定的,它没有更多的工作。 Just add this to the viewcontrollers' .h 只需将其添加到viewcontrollers的.h

@interface MyViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>

Then in the .h add the datasource and delegate functions( you could just copy and paste the functions your'e currently using in your TableViewController) 然后在.h中添加数据源和委托函数(你可以复制并粘贴你当前在TableViewController中使用的函数)

NOTE: From Xcode 4.5.1: "Static table views are only valid when embedded in UITableViewController instances." 注意:从Xcode 4.5.1:“静态表视图仅在嵌入UITableViewController实例时有效。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM