所以我有一个containerView Controller,它基本上就像splitViewController一样.
@H_404_7@
@H_404_7@我试图在containerViewController中添加一个UINavigationController,它工作得很好.
@H_404_7@我在故事板中创建了一个UINavigationController,其中连接了一堆UIViewControllers,所有这些都通过’push’segues挂钩和链接在一起.我从故事板中取出这个NavigationController,通过代码将它粘贴在我的ContainerViewController中.然后它显示了NavigationController应该在哪里,我可以单击按钮,推送动画只发生在ContainerViewController的NavigationController框架内.
@H_404_7@但是,如果我从NavigationController上的代码调用popViewController,它将为整个ContainerViewController设置动画.我不想要它,我想它只为NavigationController设置动画.
@H_404_7@有谁知道它为什么这样做?
@H_404_7@当你在ContainerViewController里面有一个UINavigationController,然后你就可以在NavigationController上使用popViewController,你如何才能使它只动画UINavigationController,而不是它所在的整个ContainerViewController?
解决方法
我也遇到过这个问题.这也影响了我的推动力.我的工作是使用代码而不是故事板segues.
@H_404_7@
@H_404_7@
- (void) switchToView:(NSString *)identifier { UIViewController *target = [self getOrCreateViewController:identifier]; [self switchToViewController:target identifier:identifier]; } // If you need to interact with the VC before it is pushed break it into 2 step process - (UIViewController *) getOrCreateViewController:(NSString *)identifier { NSArray *children = [self.viewControllers filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"restorationIdentifier == %@",identifier,nil]]; UIViewController *target = (children.count > 0 ? children[0] : [self.storyboard instantiateViewControllerWithIdentifier:identifier]); return target; } // For my use case,I always animate via push. Could modify this to pop/push as appropriate - (void) switchToViewController:(UIViewController *)target identifier:(NSString *)identifier { [self setViewControllers:[self.viewControllers filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"restorationIdentifier != %@",nil]] animated:NO]; [self pushViewController:target animated:YES]; }@H_404_7@有点Fugly解决方法我知道…希望我找到一个更好的答案(到这里寻找一个).