Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is taken from one of my applications. As you say, you are not supposed to subclass <code>UINavigationController</code>, instead you use them as they are and you add viewcontroller on the <code>UINavigationController's</code>. Then after setting the root viewcontroller in each <code>UINavigationController</code>, you add the <code>UINavigationController</code> to the <code>UITabBarController</code> (phew!). </p> <p>So each tab will "point" to a <code>UINavigationController</code> which has a regular viewcontroller as root viewcontroller, and it is the root viewcontroller (the one you add) that will be shown when a tab is pressed with a (optional) navigationbar at top.</p> <pre><code> UITabBarController *tvc = [[UITabBarController alloc] init]; self.tabBarController = tvc; [tvc release]; // Instantiates three view-controllers which will be attached to the tabbar. // Each view-controller is attached as rootviewcontroller in a navigationcontroller. MainScreenViewController *vc1 = [[MainScreenViewController alloc] init]; PracticalMainViewController *vc2 = [[PracticalMainViewController alloc] init]; ExerciseViewController *vc3 = [[ExerciseViewController alloc] init]; UINavigationController *nvc1 = [[UINavigationController alloc] initWithRootViewController:vc1]; UINavigationController *nvc2 = [[UINavigationController alloc] initWithRootViewController:vc2]; UINavigationController *nvc3 = [[UINavigationController alloc] initWithRootViewController:vc3]; [vc1 release]; [vc2 release]; [vc3 release]; nvc1.navigationBar.barStyle = UIBarStyleBlack; nvc2.navigationBar.barStyle = UIBarStyleBlack; nvc3.navigationBar.barStyle = UIBarStyleBlack; NSArray *controllers = [[NSArray alloc] initWithObjects:nvc1, nvc2, nvc3, nil]; [nvc1 release]; [nvc2 release]; [nvc3 release]; self.tabBarController.viewControllers = controllers; [controllers release]; </code></pre> <p>This is how I go from one viewcontroller to another one (this is done by tapping a cell in a tableview but as you see the pushViewController method can be used wherever you want).</p> <p>(this is taken from another part of the app)</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (self.detailedAnswerViewController == nil) { TestAnsweredViewController *vc = [[TestAnsweredViewController alloc] init]; self.detailedAnswerViewController = vc; [vc release]; } [self.navigationController pushViewController:self.detailedAnswerViewController animated:YES]; } </code></pre> <p>The <code>self.navigationcontroller</code> property is of course set on each viewcontroller which are pushed on the UINavigationController hierachy.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload