[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

    Nov 14, 2012
    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:

    -(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


    Staff Member

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

    Nov 14, 2012
    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 G3


    Nov 26, 2007
    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

    Nov 14, 2012

    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