[Resolved]. Switching from UITableViewController, to new UITabBarController

Discussion in 'iOS Programming' started by StigProgram, Nov 14, 2012.

  1. StigProgram, Nov 14, 2012
    Last edited: Nov 16, 2012

    StigProgram macrumors newbie

    Joined:
    Nov 14, 2012
    #1
    I know that to go from one TableViewController, to a new TabBarController, you can use a "segue" from the Storyboard and add the following code:

    Code:
    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
        UITabBarController *tabController = (UITabBarController *) segue.destinationViewController;
        ViewController *vc = (ViewController *) [[tabController viewControllers] objectAtIndex:0];
    }
    But I cannot use either "segue", storyboard or method -prepareForSegue:sender:

    My question is, how can I pass from TableViewController, to my new TabBarController by code?
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Why not?
     
  3. StigProgram thread starter macrumors newbie

    Joined:
    Nov 14, 2012
    #3
    Because I use a custom cell to display a Gridview (with two columns). And its design is new .xib rather than in the storyboard. I have to push the new UITabBarController on the method - tableView: didSelectRowAtIndexPath:
     
  4. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #4
    You do have a storyboard though, correct?

    Create a segue and then invoke it in code using UIViewController's performSegueWithIdentifier:sender:

    Side Question... How can we make Xcode aware of if a segue identifier doesn't exist in the storyboard files? AFAIK, Xcode emits no warnings right now about it; your first indication of a typo is when the app crashes, right?
     
  5. StigProgram thread starter macrumors newbie

    Joined:
    Nov 14, 2012
    #5
    Solved

    SOLVED. I used the method -performSegueWithIdentifier:sender: like you said ArtOfWarfare.

    In the storyboard I control-drag from my source ViewController (Grid view) to my destination TabBarController.

    In -didSelectRow method of my Grid I call -performSegueWithIdentifier:sender: thats trigger -prepareForSegue:sender: and so to implement the code necessary to complete the process
     

Share This Page