Prevent the animation when clicking quot;Backquot; button in a navigation bar?(单击“返回时阻止动画;导航栏中的按钮?)
问题描述
我的应用程序有一个导航控制器,我不希望它有任何动画:
My application has a navigation controller and I don't want any animation in it :
要在推送视图时阻止动画,很简单,通过 pushViewController:animated: 方法
to prevent an animation when pushing a view, it's easy, via the pushViewController:animated: method
但是当我点击这个子视图上的返回"按钮时,有一个动画!KO!我可以做些什么来阻止这个动画?
but when I click the "back" button on this subview, there's an animation ! KO ! What can I do to prevent this animation ?
推荐答案
更优雅的一个类别.这假设您在应用程序委托中设置了导航控制器对象.只需将其放在根视图控制器中的 @implementaion 之前即可.
More elegant with a category. This assumes you navigation controller object is set in your app delegate. Just put this before your @implementaion in the root view controller.
#import "AppDelegate.h"
@implementation UINavigationBar (custom)
- (UINavigationItem *)popNavigationItemAnimated:(BOOL)animated;
{
AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.navController popViewControllerAnimated:NO];
return TRUE;
}
@end
这篇关于单击“返回"时阻止动画;导航栏中的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!