Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Multiple table views on a single screen - nothing showing up

bvzbvz Posts: 22Registered Users
edited October 2011 in iPhone SDK Development
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!

Ben
Post edited by bvz on

Replies

  • bvzbvz Posts: 22Registered Users
    edited August 2008
    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?

    So many questions... but it's 2 am and I need to sleep... :)
  • usmanismailusmanismail Posts: 13Registered Users
    edited September 2008
    -(void)loadView
    {


    // create and configure the view
    CGRect cgRct = CGRectMake(0, 10, 320, 100); //define size and position of view
    myView = [[UIView alloc] initWithFrame:cgRct]; //initilize the view
    myView.autoresizesSubviews = YES; //allow it to tweak size of elements in view
    self.view = myView; //set view property of controller to the newly created view
    UITableView * tableView = [[UITableView alloc] initWithFrame:cgRct style:UITableViewStylePlain];
    tableView.editing = YES;
    tableView.dataSource = self;
    tableView.delegate = self;


    cgRct = CGRectMake(0, 120, 320, 100); //define size and position of view
    UITableView * tableView1 = [[UITableView alloc] initWithFrame:cgRct style:UITableViewStylePlain];
    tableView1.editing = YES;
    tableView1.dataSource = self;
    tableView1.delegate = self;

    cgRct = CGRectMake(0, 230, 320, 100); //define size and position of view
    UITableView * tableView2 = [[UITableView alloc] initWithFrame:cgRct style:UITableViewStylePlain];
    tableView2.editing = YES;
    tableView2.dataSource = self;
    tableView2.delegate = self;

    [self.view addSubview:tableView];
    [self.view addSubview:tableView1];
    [self.view addSubview:tableView2];



    }


    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.

    --regards
    Usman Ismail
  • bvzbvz Posts: 22Registered Users
    edited September 2008
    Cool! Thanks. I'm going to give it a shot early next week but it looks like it should work.

    ben
  • PhoneyDeveloperPhoneyDeveloper Posts: 1,431Registered Users
    edited September 2008
    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.
    TestTableViewController.zip
    1 x 1 - 17K
  • zulfishahzulfishah Posts: 203Registered Users @ @
    edited January 2009
    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?
    Check out my apps:<br />
    <br />
    <a href="http://appsto.re/contactsjournal" target="_blank"> Contacts Journal</a><br />
    <br />
    <a href="http://appsto.re/ContactsJournalLite" target="_blank"> Contacts Journal Lite</a><br />
    <br />
    <a href="http://itun
  • VManVMan Posts: 184Registered Users
    edited March 2009
    PhoneyDeveloper,

    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?

    - (UITableViewCell * )tableView: (UITableView * )tableView cellForRowAtIndexPath: (NSIndexPath * )indexPath

    I would think Apple designed these delegate methods to receive the tableView argument to allow for multiple tables in the same controller class..?
  • PhoneyDeveloperPhoneyDeveloper Posts: 1,431Registered Users
    edited March 2009
    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.
  • VManVMan Posts: 184Registered Users
    edited March 2009
    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.


    Is there a way for me to know what the (UITableView *)tableView parameter is for either of my tables?

    I interrupted my code in the delegate method with:

    NSLog (@"tableView is equal to %@",tableView);

    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?

    Thanks again. You truly are one of the most helpful on this forum.
  • PhoneyDeveloperPhoneyDeveloper Posts: 1,431Registered Users
    edited March 2009
    You need an outlet to the tableview or an ivar that holds the pointer for the tableviews. Then a simple comparison will work.
    if (tableView == tableView1)
    {
    // table view 1 case
    }
    else
    {
    // table view 2 case
    }
    

    BTW, use %p to print pointers.

    Thanks for the compliments.
  • VManVMan Posts: 184Registered Users
    edited March 2009
    PhoneyDeveloper,


    Everything works perfectly! Thanks again!
  • KayzKayz Posts: 1New Users
    edited March 2009


    hi

    at first thanks very much for this article it gave me many help.

    i would like add a question please.


    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

    thanks for your help
  • PhoneyDeveloperPhoneyDeveloper Posts: 1,431Registered Users
    edited March 2009
    initWithCoder
    awakeFromNib
    viewDidLoad
    
    take your pick.
  • harrycharryc Posts: 1New Users
    edited June 2009
    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!
  • ChetmunChetmun Posts: 22Registered Users
    edited August 2009
    Have you taken your three-table example down? I only see a tutorial for a view with one table (which is very useful on its own).
  • jimbob1971jimbob1971 Posts: 8New Users
    edited November 2009
  • kyle_of_klanackkyle_of_klanack Posts: 1New Users
    edited July 2010
    Merci PhoneyDeveloper, c'est exactement ce qu'il me fallait !
  • gpg84gpg84 Posts: 1New Users
    edited November 2010
    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.
  • Elf SundaeElf Sundae Posts: 1New Users
    edited November 2010
    Thanks PhoneyDeveloper very much,and I have done all!.

    ps.This is my first post on iphoneDevSdk :)
  • rclarke407rclarke407 Posts: 1New Users
    edited August 2011
    I based my iPad app on your code, copying exactly the code and linking the IB objects. The app opens and displays the two tables, but they are empty and I get this error in the debugger:

    Unknown class MyTableViewControllerTwo in Interface Builder file.

    Any idea what I'm missing? I have checked and rechecked, but I must be missing something :) Thanks!
    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.
  • timeviewtimeview Posts: 5New Users
    edited October 2011
    gpg84 wrote: »
    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).
  • timeviewtimeview Posts: 5New Users
    edited October 2011
    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).

    Anyone?

    Thanks
Sign In or Register to comment.