views:

310

answers:

3

Hi all!

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  A: 

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.

TahoeWolverine
I tried that, but then I can't use a UITableViewController; it wouldn't accept the regular view!
Aviad Ben Dov
+1  A: 

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.

Ramin
When you say iVar you mean IBOutlet? :)
Aviad Ben Dov
It can be an IBOutlet but you can also create and place it programmatically. Probably easier to tweak in IB and assigned to an IBOutlet.
Ramin
A: 

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.

tt.Kilew
That would have been great if I could contain a UITableViewController in my new UIViewController, and delegate calls to "normal" UITVC messages to the delegate. However, is there a way to determine if a message belongs to the UITVDataSource or UITVDelegate so that I can delegate these only? Or will it have to be hard-coded?
Aviad Ben Dov