防止UINavigationBar popViewController动画 [英] Prevent UINavigationBar popViewController animation

查看:108
本文介绍了防止UINavigationBar popViewController动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题:我已覆盖 popViewControllerAnimated:(BOOL)动画 of UINavigationController 因为我想有一个自定义动画。代码如下:

I have the following problem: I have overridden popViewControllerAnimated:(BOOL)animated of UINavigationController because I would like to have a custom animation. The code is as follows:

- (UIViewController *)popViewControllerAnimated:(BOOL)animated 
{
    UIViewController *poppedCtrl = [super popViewControllerAnimated:NO];
    [((customViewController *) self.topViewController) doCustomAnimation];
    return poppedCtrl;
}

不幸的是 UINavigationBar 似乎忽略了我明确禁用内置动画并且它仍然是动画的。

Unfortunately the UINavigationBar seems to ignore that I explicitly disable the built in animation and it is still animated.

我还需要做些什么才能阻止导航栏的动画?

What do I have to do to also prevent the animation of the navigation bar?

推荐答案

经过一些阅读和一些实验后,我终于找到了为实现理想行为需要做些什么。

After some reading and also some experimentation I finally found out what needs to be done to achieve the desired behavior.

为了防止导航栏被动画,仅覆盖(UIViewController *)popViewControllerAnimated:(BOOL)动画

To prevent the navigation bar from being animated it is not sufficient to override (UIViewController *)popViewControllerAnimated:(BOOL)animated.

还需要创建自定义导航栏并覆盖(UINavigationItem *)popNavigationItemAnimated:(BOOL)动画

It is also necessary to create a custom navigation bar and override (UINavigationItem *)popNavigationItemAnimated:(BOOL)animated:

- (UINavigationItem *)popNavigationItemAnimated:(BOOL)animated {
    return [super popNavigationItemAnimated:NO];
}

当然这个自定义导航栏也必须是使用的导航栏(I刚刚更换了导航控制器在界面构建器中使用的导航栏。

Of course this custom navigation bar must also be the one which is used (I just replaced the navigation bar which is used by my navigation controller in the interface builder).

这篇关于防止UINavigationBar popViewController动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆