Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top