Commits

Christopher Denter  committed 08b2cb3

Make each tabbed VC have its own nav vc

  • Participants
  • Parent commits 3fa526b

Comments (0)

Files changed (1)

File iOS7Tests/BAViewController.m

 {
     [super viewDidLoad];
 
+    UIViewController* (^ScrollingVC)(UIColor *) = ^(UIColor *color){
+        UIViewController *vc = [[BAScrollingTestViewController alloc] initWithColor:color];
+
+        // Wrap it in a nav vc
+        vc = [[UINavigationController alloc] initWithRootViewController:vc];
+
+        return vc;
+    };
+
     UITabBarController *tabController = [[UITabBarController alloc] init];
-    tabController.viewControllers = @[
-                                      [[BAScrollingTestViewController alloc] initWithColor:[UIColor redColor]],
-                                      [[BAScrollingTestViewController alloc] initWithColor:[UIColor greenColor]],
-                                     ];
+    tabController.viewControllers = @[ScrollingVC([UIColor redColor]), ScrollingVC([UIColor greenColor])];
     tabController.view.backgroundColor = [UIColor lightGrayColor];
 
-    UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:tabController];
-    navVC.view.frame = self.view.bounds;
-    [self addChildViewController:navVC];
-    [self.view addSubview:navVC.view];
-    [navVC didMoveToParentViewController:self];
+    UIViewController *rootVC = tabController;
+
+    rootVC.view.frame = self.view.bounds;
+    [self addChildViewController:rootVC];
+    [self.view addSubview:rootVC.view];
+    [rootVC didMoveToParentViewController:self];
 }
 
 @end