我正在关注this答案,以便在UINavigationController中“释放”我之前的视图控制器。使用自定义Segue流行UIViewController?
它工作正常,但弹出部分是我难以开始工作的代码。基本上我的应用程序是这样工作的。它从一个主菜单(视图1)开始,然后推到视图2,并使用自定义push segue来查看视图3.现在我想使用不同的自定义视图,现在从弹出视图3到视图2。但是,通过使用下面的代码,它很快地弹出到视图1,然后最终推到视图2.它看起来像视图控制器转换是不自然的,我只是想实现通常的弹出转换,而不是通过使用自定义的继续以“释放”源视图控制器。
这是我的代码,我现在使用无济于事:
- (void)perform {
// Grab Variables for readability
UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
UINavigationController *navigationController = sourceViewController.navigationController;
// Get a changeable copy of the stack
NSMutableArray *controllerStack = [NSMutableArray arrayWithArray:navigationController.viewControllers];
// Replace the source controller with the destination controller, wherever the source may be
[controllerStack addObject:destinationController];
// Assign the updated stack with animation
[navigationController setViewControllers:controllerStack animated:YES];
}
有什么我做错了吗?
你试过[navigationController pushViewController:destinationController animated:YES]; –
@NiravDoctorwala是的,但是这并没有解决问题。另一个问题是我特别寻找“流行”动画,而不是“推动”。 –
http://stackoverflow.com/questions/10281545/removing-viewcontrollers-from-navigation-stack –