iOS 从导航控制器控制后退按钮



我有三种观点:1)我的标签栏上的首字母2) 从 #1 开始查看3) 从 #2 开始查看

该应用程序的正常使用是从#1开始,转到#2,然后转到#3,这将始终返回到#2。 我希望 #2 的后退按钮始终返回到 #1。 但是,在输入 #3 并返回到 #2 后,后退按钮转到 #3(相反,我想要 #1)。 我目前使用推送 segue。 关于如何更新它的任何想法?

使用:

popToRootViewControllerAnimated:

而不是:

popViewControllerAnimated:

我最终使用此链接解决了从导航堆栈中删除视图控制器并用 if 语句将其包围以检测至少 2 个视图控制器:

 - (void) viewWillDisappear:(BOOL)animated{
NSMutableArray *navigationArray = [[NSMutableArray alloc] initWithArray: self.navigationController.viewControllers];
int i = [navigationArray count];
// [navigationArray removeAllObjects];    // This is just for remove all view controller from navigation stack.
if (i > 1){
    NSLog(@"count: %d", i);
    [navigationArray removeObjectAtIndex: 1];  // You can pass your index here
    self.navigationController.viewControllers = navigationArray;
}
}

最新更新