简体   繁体   English

iPhone如何在离开视图控制器时关闭动画

[英]iPhone how to turn off animation on leaving a view controller

Im wondering how I can turn off the animation of my view controller when leaving back to the parent controller. 我想知道当回到父控制器时如何关闭视图控制器的动画。 As I can set the animation property for going to the child controller, I guess there must surely be a way to set the property for the leaving task. 因为我可以设置动画属性以转到子控制器,所以我想肯定有一定方法可以为离开任务设置属性。

Thanks, Markus 谢谢,马库斯

It's quite simple. 这很简单。 You have to change the back button behavior. 您必须更改后退按钮的行为。

Create this function in your view controller 在视图控制器中创建此功能

- (void) popWithoutAnimation {
[self.navigation.controller popViewControllerAnimated:NO];
}

Then change the backBarButtonItem behavior (in your viewDidLoad) : 然后更改backBarButtonItem行为(在viewDidLoad中):

self.navigationItem.backBarButtonItem.action = @selector(popWithoutAnimation);
self.navigationItem.backBarButtonItem.target = self;

Don't care about syntax I'm just giving you the clues to solve your issue 不在乎语法,我只是为您提供解决问题的线索

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM