Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

StigProgram

macrumors newbie
Original poster
Nov 14, 2012
5
0
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?
 
Last edited:

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:
 
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?
 
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.