1

Well I have read those posts and tutorials but they made me more confused:

url 1 quest 1 quest 2

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:

navigation controller single view

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: enter image description here

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.

Community
  • 1
  • 1
ghostrider
  • 5,131
  • 14
  • 72
  • 120

2 Answers2

1

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];
Desdenova
  • 5,326
  • 8
  • 37
  • 45
  • I get this error: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard () doesn't contain a view controller with identifier 'SkiCentersIds'' I gave either my TabBar Controller the name SkiCenterIds or in mu UIViewController (tab 1) that name but neither of the worked. – ghostrider Sep 06 '12 at 14:35
  • 1
    `UITabBarController`'s id should be SkiCentersIds. – Desdenova Sep 06 '12 at 14:44
0

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]];
James Paolantonio
  • 2,194
  • 1
  • 15
  • 32
  • No it's called SkiCenter. Ski center is the name of UIView (tab 1) in sollution number 2. But there is no connection between navigation bar controller and tab bar controller (in sollution 2 again) – ghostrider Sep 06 '12 at 13:49
  • In solution 1, is the file name not SkiCenterMain.xib? You need to create a tabBarController there, not just a UIView. Then change the tabBarController's class to SkiCenter. – James Paolantonio Sep 06 '12 at 13:55
  • Yes but I cannot embed my view in TabBarControoller. This ooption cannot be pressed. The view opens normally so .xib is right but there it is just a single view. – ghostrider Sep 06 '12 at 14:05
  • Yes, you should not embed a view in the UITabBarController. Instead, set your view as the view property of a UIViewController. Then embed the UIViewController as one of the UITabBarController's tabs. – James Paolantonio Sep 06 '12 at 14:14
  • I did the first one, but the again UIViewController cannot be embdedded in UTabBar Controller. – ghostrider Sep 06 '12 at 14:36
  • You can embed a UIViewController in a tabBar. Try this: http://www.cimgf.com/2009/06/25/uitabbarcontroller-with-uinavigationcontroller-using-interface-builder/ – James Paolantonio Sep 06 '12 at 14:42