在我的库中,我有一个加载视图,弹出到输入视图。当用户完成输入视图时,它应该返回加载视图再次做一些魔法,完成后应该显示第三个视图。
现在,从可用性视图中我不想“滑回”到加载视图,当我已经在内存中时,我也不想分配新的加载视图。
在向前滑动视图时,有什么方法可以popToRootViewController吗? (是的,我删除了加载视图中的后退按钮)..
答案 0 :(得分:2)
MagicViewController *magicVC = [[MagicViewController alloc] init];
magicVC.setModalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:magicVC animated:true];
然后当魔术视图控制器完成它的魔法时,只需在那一点(你弹出的地方):
[self dismissModalViewControllerAnimated:true];
这比做简单的导航要凉爽得多。
答案 1 :(得分:2)
好的就是 - 也许尝试使用这样的东西
// This goes in whatever view controller you want to pop with
- (void)popToRootWithForwardAnimation
{
NSMutableArray * viewControllers = [[[self.navigationController viewControllers] mutableCopy] autorelease]
UIViewController * rootViewController = [viewControllers objectAtIndex:0]
[viewControllers removeObjectAtIndex:0]; // try using with and without this line?
[viewControllers addObject:rootViewController];
[self.navigationController setViewControllers:viewControllers animated:YES];
}
// This goes in the root view controller
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated]
NSMutableArray * viewControllers = [[[self.navigationController viewControllers] mutableCopy] autorelease]
if ([viewControllers count] > 1)
{
[viewControllers removeAllObjects];
[viewControllers addObject:self];
[self.navigationController setViewControllers:viewControllers animated:NO];
}
…
…
}