将NavigationController设置为初始控制器

时间:2016-01-21 00:29:42

标签: ios objective-c

我有两个导航控制器。如何设置第二个 - stopwatch作为初始导航控制器?

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];

    self.swipeBetweenVC = [Swipe new];
    [self setupRootViewControllerForWindow];
    self.window.rootViewController = self.swipeBetweenVC;

    [self.window makeKeyAndVisible];

    return YES;
}

- (void)setupRootViewControllerForWindow
{
    UIStoryboard *storyboard1 = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
    Stopwatch *controller1 = (Stopwatch *)[storyboard1 instantiateViewControllerWithIdentifier:@"Stopwatch"];
    UINavigationController *stopwatch = [[UINavigationController alloc] initWithRootViewController:controller1];

    NamesController *controller2 = (NamesController *)[storyboard1 instantiateViewControllerWithIdentifier:@"NamesController"];
    UINavigationController *namesList = [[UINavigationController alloc] initWithRootViewController:controller2];

    self.swipeBetweenVC.viewControllers = @[namesList, stopwatch];
}

2 个答案:

答案 0 :(得分:0)

先把秒表视图放在

 self.swipeBetweenVC.viewControllers = @[stopwatch, namesList];

答案 1 :(得分:0)

目前您有一些滑动类型设置为根VC,更改为self.window.rootViewController = stopwatch;