setNavigationBarHidden与animation不工作在iPad上

当用户点击一个button时,我在我的应用程序中使用下面的代码:

[self.navigationController setNavigationBarHidden:NO animated:YES]; 

外观通常在iPhone上animation,而不是在iPad上。 你知道为什么吗 ?

这里最好的解决scheme可能是把self.navigationBar.hidden = NO; 在UIViewController的-viewWillAppear:方法,你不希望永远隐藏酒吧。

编辑:

我发现这一点,可能会帮助你;

 if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) { CGRect rect = self.navigationController.navigationBar.frame; rect.origin.y = rect.origin.y < 0 ? rect.origin.y + rect.size.height : rect.origin.y - rect.size.height; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.2]; self.navigationController.navigationBar.frame = rect; [UIView commitAnimations]; } else { [self.navigationController setNavigationBarHidden:shouldHide animated:YES]; } 

你确定你是在主线程的上下文中调用这个吗?

检查你写的其他代码以及你的视图的属性。 我在我的通用应用程序中使用这个片段,它在iPhone和iPad上都能正常工作。 所以看起来像其他设置(可能是自动调整属性?)的意见是造成这一点。

这段代码对我来说工作正常。 我尝试与iPhone导航模板,然后该项目升级为两个特定的设备的iPad。 并运行在iPad上。 然后导航栏隐藏/显示与iPhone应用程序一样的animation。

尝试这个。 愿你有更多的想法。

谢谢,

MinuMaster