iPhone - Replacing rootview in navigation controller

后端 未结 2 758
栀梦
栀梦 2020-12-13 09:04

I have a project with a NavigationController, that contains into IB the first ViewController to show. That\'s just the default pattern when creating the project.

In

相关标签:
2条回答
  • 2020-12-13 09:38

    From UINavigationController reference:

    This method (popViewControllerAnimated:) removes the top view controller from the stack and makes the new top of the stack the active view controller. If the view controller at the top of the stack is the root view controller, this method does nothing. In other words, you cannot pop the last item on the stack.

    You can try the setViewControllers:animated: method instead.

    - (void) goNext {
    
        NextViewController* nextWindow = [[[NextViewController alloc] initWithNibName:@"NextView" bundle:nil] autorelease];
        [self.navigationController setViewControllers:[NSArray arrayWithObject:detailViewController] animated:YES];
    }
    
    0 讨论(0)
  • 2020-12-13 09:41

    If the view controller at the top of the stack is the root view controller, popViewControllerAnimated does nothing. In other words, you cannot pop the last item on the stack.

    To replace the root view controller use this method:

    - (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
    
    0 讨论(0)
提交回复
热议问题