2015-12-19 18 views
1

我已经视图A,图B和图C.我已经从视图中的推视图B和从视图B.推视图CpopToRootViewControllerAnimated当用户滑动回

当鉴于C返回按钮用户抽头,我调用popToRootViewControllerAnimated,以便用户根本不会看到视图B.

问题是,如果用户在视图C中向后滑动,他们仍然会看到视图B.我不希望用户看到视图B,并直接跳到视图A.我应该怎么做?

我目前使用xib。

回答

2

视图控制器C出现时,您可以更改NavigationController的堆栈按钮。使用下面的代码: -

NSMutableArray *aMutArr = [NSMutableArray arrayWithArray:self.navigationController.viewControllers]; 
[aMutArr removeObjectAtIndex:aMutArr.count-2]; 
self.navigationController.viewControllers = aMutArr; 

我已经从堆栈中删除了ViewController B.所以如果你的用户滑动回来,他将能够看到ViewController A.

+0

太棒了。它完全解决了我的问题。 –

0

你可以关掉刷卡回功能

if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { 
self.navigationController.interactivePopGestureRecognizer.enabled = NO; 
} 

以这种方式,用户只能回去通过您所提供

相关问题