【发布时间】:2016-10-14 16:42:24
【问题描述】:
我正在关注this 在 UINavigationController 中“释放”我以前的视图控制器的回答。
它工作正常,但弹出部分是我难以开始工作的代码。基本上我的应用程序是这样工作的。它从主菜单(视图 1)开始,然后推送到视图 2,我使用自定义推送转场到达视图 3。现在我想使用不同的自定义转场来弹出从视图 3 到视图 2。但是,通过使用下面的代码,它非常快速地弹出到视图 1,然后最终推送到视图 2。看起来视图控制器转换是不自然的,我只是想通过使用自定义 segue 来实现通常的弹出转换“释放”源视图控制器。
这是我现在使用的代码,但无济于事:
- (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 是的,但这并不能解决问题。另一个问题是我专门寻找“流行”动画,而不是“推动”。
标签: ios uinavigationcontroller transition uistoryboardsegue