Help passing table data after segue performed

Discussion in 'iOS Programming' started by Dman90, Jan 24, 2012.

  1. Dman90 macrumors newbie

    Joined:
    Jun 25, 2011
    #1
    Hi Guys,

    I have a simple login page, and when the user enters the right details, its loads a new page. The new page is meant to be a table with 4 coloums. However when I perform segue, an empty table controller is loaded, with no information at all.

    This is the code I use:

    Code:
    mainTableController *aaa = [[mainTableController alloc] initWithStyle:UITableViewStylePlain];
        UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:aaa];
        
        [self presentModalViewController:navController animated:YES];
    
    How Do I make sure the data is loaded with the segue?

    Any help would be appreciated.

    ----------

    Also, My table is static, with 4 coloums. Each of these coloums include a UIImage and a label.
     
  2. ArtOfWarfare, Jan 24, 2012
    Last edited: Jan 24, 2012

    ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    Have you looked into the prepareForSegue: method?
     
  3. Dman90 thread starter macrumors newbie

    Joined:
    Jun 25, 2011
    #3
    Yes I have looked at it, but I'm not sure how to assign 4 pictures, and 4 labels to my static table once it joins?
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    You should also review your naming standards. mainTableController as the name of a class? You sure that's what you want?
     
  5. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #5
    Based on looking at your code, I don't think you're using a segue. (A segue is the transition that you would set up between views in a storyboard file.)

    For what you have right there, I don't know what the most "correct" way of doing it is, but I'd probably have several properties for mainTableController which I would assign after creating the table and before presenting it.

    It'd go something like:

    Code:
    mainTableController *aaa = [[mainTableController alloc] initWithStyle:UITableViewStylePlain];
    UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:aaa];
    aaa.string1 = @"Something passed.";
    aaa.string2 = @"Another thing passed.";
    [self presentModalViewController:navController animated:YES];
    In the cellForRow method, I'd then assign the contents of the cells to be equal to the strings.

    Except... you're using static cells? I haven't used those before, but I remember those were mentioned in the tutorial I've posted a link to below, which if you read through parts 1 and 2, I think should answer your question...

    http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1
     

Share This Page