UITableView and a UITextField that is always visible

让人想犯罪 __ 提交于 2019-12-23 02:39:08

问题


I want to create an application which combines a chat feature. My question is this: how can I have a UITextField that is always visible in the same view as a UITableView?

The obvious solution would be to create my own UIView having a UITableView and a UITextField below it, however the UITableViewController doesn't seem to like me doing that as it expects the connected "view" outlet to be a UITableView, essentially destroying my plans.

Anyone with an idea?


回答1:


Don't use UITableViewController. After all, it's just a standard controller with a full-screen UITableView. You can roll your own easily.

Use a standard UIViewController and have it implement UITableViewDelegate and UITableViewDataSource protocols (you don't need to implement every method -- just the required ones). Then give it a UITableView as an iVar and set the delegate and dataSource to self. Size it so it only takes half the screen and your other views take the other part. You can lay out the whole thing in IB or create and position view+table manually.




回答2:


I would suggest sticking a regular view in between your controller and your smaller "half-views". That has usually cleared things up for me, or at least exposed what the problem might be.




回答3:


If you don't need functionality that UITableViewController provided, than you can just use UIViewController with <UITableViewDataSource, UITableViewDelegate> protocols. So, your main viewController will accept any type of views.



来源:https://stackoverflow.com/questions/1210821/uitableview-and-a-uitextfield-that-is-always-visible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!