Reputation: 5259
Well I have read those posts and tutorials but they made me more confused:
What i want is to do this:
At the beginning my app, has a table view. when I press a row, it should take me to another view which has tabs.
What I did so far was these:
1) Created a navigation controller , and there is my tableview. When I press a row, a single view opens. In that view (with its own .xib file) I added tab bars items.
You can see pictures here:
But now, I don't know how to make it when pressing a tab bar item, to open a new view. I am trying to embed my view in a controller but I cannot.
2) Then I tried this: Having my navigation controller as before and I added in storyboard a tabbar controller like in that picture:
But I cannot connect them. My first view is class "SkiCenter" and code I am using is:
SkiCenter *myDetViewCont = [[SkiCenter alloc] initWithNibName:@"SkiCenter" bundle:[NSBundle mainBundle]];
myDetViewCont.ski_center=[centers objectAtIndex:indexPath.row];
[self.navigationController pushViewController:myDetViewCont animated:YES]; // "Pushing the controller on the screen"
[myDetViewCont release]; // releasing controller from the memory
myDetViewCont = nil;
and I get SIGBRT that says something about .nib file for "SkiCenter".
Can you suggest a sollution in either 1 or 2?
just to make it more clear: Solution 1: pressing the row gets me to a single uiview named skicentermain. I have added several tabbaritems but I do not know how to make them open new views.
Sollution 2: Inserted a tabbar controller. Its first tab is SkiCenter. But when pressing the row, I get a sigbart error. it says something about the nib file of SkiCenter.
Upvotes: 1
Views: 545
Reputation: 5378
If you decide to use storyboard you can simply put an identifier to any view controller from attributes inspector
and then instantiate it with its id.
UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
[[self navigationController] pushViewController:[storyBoard instantiateViewControllerWithIdentifier:@"ViewControllerID"] animated:YES];
Upvotes: 1
Reputation: 2194
It looks like your declaring your *myDetViewCont
incorrectly. You called your nib SkiCenterMain, not SkiCenter. Also, what exactly is on SkiCenterMain? Is that a UITabBarController?
//SkiCenter *myDetViewCont = [[SkiCenter alloc] initWithNibName:@"SkiCenter" bundle:[NSBundle mainBundle]];
SkiCenter *myDetViewCont = [[SkiCenter alloc] initWithNibName:@"SkiCenterMain" bundle:[NSBundle mainBundle]];
Upvotes: 0