Multiple table views on a single screen - nothing showing up

I have three table views on a single screen (as subviews of a master view created in IB). Alas my app just shows me a black screen and the gdb gives me this cryptic warning:

This GDB was configured as "i386-apple-darwin".warning: Unable to read symbols for "/System/Library/Frameworks/UIKit.framework/UIKit" (file not found).
warning: Unable to read symbols from "UIKit" (not yet mapped into memory).

The way I handled it (and correct me if this seems like a dumb way to do it) was to create three separate tableViewController subclasses and add them to the xib file as proxy objects (connecting the datasource and delegate and view connections as required).

As it turns out, just adding a single proxy object (but not changing it's type from NSObject or wiring it up to anything) gives me this same black screen (and same warning messages). So, for example, I have a single table view and a single extra proxy object (not hooked into anything). This will also give me a black screen and the warnings. Removing the proxy object (but leaving in the tableView) lets me actually see the table view and I do not get the warnings.

I googled the error message but did not find anything of use. Does anyone here have any ideas? Thanks in advance!

Replies

Ok, just had a mini-brain storm here. I think the reason this does not work is because the proxy objects are just that... proxy objects. They do not get instantiated when the xib file is loaded.

This now leaves me with the question... how do I actually make something like this work (three table views on a single screen). Is it the best idea to have a separate tabelViewController subclass for each tableView?

If I have a viewController subclass loading the view inside of which these table views live (I dragged them there using IB), do I instantiate the tableViewController subclasses inside of this viewController? And how do I connect them to the individual table views inside the single xib file?

Maybe I should have each table view in a separate xib file and then combine them programatically?

I tried this code and it loaded three views on one page. You can download the XCode project at my site (Projects & Source Code) and replace the load view function in that code with this one to see multiple tables.

The warning from GDB is unimportant. It always will show up with anything you run in the simulator. It's not relevant to the problems you are having.

First, is it possible that you can use a grouped table with three sections for your UI? That will be much simpler than having three separate tables in one view.

Setting up the UI you want is possible but there are a lot of little details to get right. I've attached a project that shows two table views at the same time. Almost everything is set up in IB.

Summary:

Started with View-based app template.

Added two UITableViewController subclasses to the project. (These are trivial and just create NSArray instances containing the strings that are the contents of their tableview rows.)

In the viewcontroller.xib file added two tableview controllers from the Library and set the Class Identity of these to the UITableViewController subclasses I just created in the project.

Dragged the tableviews from these two view controllers into the main view and set their size, position and autoresizing properties.

Unchecked the 'Autoresize View To Fill Screen' checkbox for the controllers.

Added two UITableViewController IBOutlets to the Main View controller's header and hooked these up in IB. This step is critical, although I don't know why. The controllers seem to be built even if these outlets don't exist but the table views don't appear if they don't exist.

Also had to set the view outlet for the table view controllers in IB back to the two table views that are now inside the main view.

It is necessary to check all the connections in IB very carefully. Use the list view mode. Control click on all the objects and inspect the little window that appears showing the outlet connections to see that everything is correct.

Hi,
I was following the example below and got this working partially, where 2 table views show up in one view, but they don't seem to link to the NSArray I have defined in the table controller classes. There's one point here which I can't seem to do in IB:

"In the viewcontroller.xib file added two tableview controllers from the Library and set the Class Identity of these to the UITableViewController subclasses I just created in the project."

When I drag tableview controllers to the .xib file, it doesn't let me change the class identity. So how did this work for you?

Thank you so much for helping us all out this time and for the many other times I've been fortunate enough to see your replies to other threads.

Is there a way to just have the same view controller class differentiate between 2 different tables placed on the same view through IB by using the (UITableView *)tableView argument that's sent to the delegate methods?

Yes, that's the point of the tableView parameter, so you can compare it to your tableView1, tableView2 ivars. These will be outlets if you're using IB.

Obviously table views are complicated with all of the callbacks so it may be simpler to have two separate view controllers if you have two tables but you can use only one if that's what you want. This is a common pattern with all the delegate methods throughout Cocoa.

BTW, in my old post I said

Added two UITableViewController IBOutlets to the Main View controller's header and hooked these up in IB. This step is critical, although I don't know why. The controllers seem to be built even if these outlets don't exist but the table views don't appear if they don't exist.

I now understand this. The table view controllers in that project are top level
objects and top level objects must be retained by the File's Owner. If they're not retained they will be dealloced shortly. Normally the only top level object retained by the file's owner is the view outlet. All the other outlets are also retained, either implicitly or explicitly. So the outlets that I added in that code served to retain the two table view controllers. They would also need to be released in the main view controller's dealloc method.

And each time I scroll either of my two tables, I get 2 different sets of numbers that I'm guessing are memory addresses. But each time I run the application, the set of 2 memory addresses are different each time.

How can I know what (UITableView *)tableView parameter to use in my delegate code to return the correct UITableViewCell?

if i understood well , MyTableViewController or MyTableViewControllertwo 's class are automaticly instantiate by IB (implicite) and retain by the two outlets.

but if MyTableViewController or MyTableViewControllertwo need to receive an pointer from an external class , for example a pointer
from an NSMutablearray .

how i can do this ? i have not the control of MyTableViewController 's constructor because is not instantiate manually i cannot instantiate the object and send my argument on my surcharging constructor

The warning from GDB is unimportant. It always will show up with anything you run in the simulator. It's not relevant to the problems you are having.

First, is it possible that you can use a grouped table with three sections for your UI? That will be much simpler than having three separate tables in one view.

Setting up the UI you want is possible but there are a lot of little details to get right. I've attached a project that shows two table views at the same time. Almost everything is set up in IB.

Summary:

Started with View-based app template.

Added two UITableViewController subclasses to the project. (These are trivial and just create NSArray instances containing the strings that are the contents of their tableview rows.)

In the viewcontroller.xib file added two tableview controllers from the Library and set the Class Identity of these to the UITableViewController subclasses I just created in the project.

Dragged the tableviews from these two view controllers into the main view and set their size, position and autoresizing properties.

Unchecked the 'Autoresize View To Fill Screen' checkbox for the controllers.

Added two UITableViewController IBOutlets to the Main View controller's header and hooked these up in IB. This step is critical, although I don't know why. The controllers seem to be built even if these outlets don't exist but the table views don't appear if they don't exist.

Also had to set the view outlet for the table view controllers in IB back to the two table views that are now inside the main view.

It is necessary to check all the connections in IB very carefully. Use the list view mode. Control click on all the objects and inspect the little window that appears showing the outlet connections to see that everything is correct.

This is a really good example. While keep both tables on the same screen, how to only make one of those tables visible at any one time and then switch between the two, say, if selecting the third row of the first table, it would make the first table hidden and bring up the second table? Thanks!

Hi PhoneyDeveloper
i followed your code to have multiple table views in a single view. Its great. I got what i wanted. THanks a lot. But there is a problem.
In my program i am using 2 table views side by side. When i click one of the rows its should take me its sub table view To populate data in the table views and sub table views i have a plist file. Now when I run the program both the table views are loaded and data is populated from the plist file. Then when i click the row of the table nothing happens. No error or except is shown. The sub table views are not loaded from the plist file.

The warning from GDB is unimportant. It always will show up with anything you run in the simulator. It's not relevant to the problems you are having.

First, is it possible that you can use a grouped table with three sections for your UI? That will be much simpler than having three separate tables in one view.

Setting up the UI you want is possible but there are a lot of little details to get right. I've attached a project that shows two table views at the same time. Almost everything is set up in IB.

Summary:

Started with View-based app template.

Added two UITableViewController subclasses to the project. (These are trivial and just create NSArray instances containing the strings that are the contents of their tableview rows.)

In the viewcontroller.xib file added two tableview controllers from the Library and set the Class Identity of these to the UITableViewController subclasses I just created in the project.

Dragged the tableviews from these two view controllers into the main view and set their size, position and autoresizing properties.

Unchecked the 'Autoresize View To Fill Screen' checkbox for the controllers.

Added two UITableViewController IBOutlets to the Main View controller's header and hooked these up in IB. This step is critical, although I don't know why. The controllers seem to be built even if these outlets don't exist but the table views don't appear if they don't exist.

Also had to set the view outlet for the table view controllers in IB back to the two table views that are now inside the main view.

It is necessary to check all the connections in IB very carefully. Use the list view mode. Control click on all the objects and inspect the little window that appears showing the outlet connections to see that everything is correct.

Hi PhoneyDeveloper
i followed your code to have multiple table views in a single view. Its great. I got what i wanted. THanks a lot. But there is a problem.
In my program i am using 2 table views side by side. When i click one of the rows its should take me its sub table view To populate data in the table views and sub table views i have a plist file. Now when I run the program both the table views are loaded and data is populated from the plist file. Then when i click the row of the table nothing happens. No error or except is shown. The sub table views are not loaded from the plist file.

Could you please help me with this. I am unable to understand.

Thanks a ton for your help.

Did you find an answer? - I too have two tables in one view working but on one I trying to push an subview (based on SimpleEKdemo - calendar apple code) I also don't detail view (It is being called).

I used the two tables example but the problem I having is one of the tables wants to use Navigation controller to pop another viewcontroller on top it seems that pushViewController:anotherViewController animated:YES]; will not work within the table view - it will work if I in the enclosing view controller (the one holding the two table views).