setNavigationBarHidden with animation not working on iPad

微笑、不失礼 提交于 2019-12-12 23:07:33

问题


I use the following code in my app when user click on a button :

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

The appearance animates normally on iPhone but not on iPad. Do you know why ?


回答1:


The best solution here may be to put self.navigationBar.hidden = NO; in the -viewWillAppear: method of the UIViewController where you dont wish to have the bar perpetually hidden.

EDIT:

i found this, may help you;

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];
}



回答2:


Are you sure you're invoking this in the context of the Main Thread ?




回答3:


Do check the other code you have written along with the properties of your view. I use this fragment in my universal apps and it works fine on both the iPhone and iPad. So looks like some other setting (probably autosizing properties??) of your views are causing this.




回答4:


This code is working fine for me. I try with navigation templete for iphone and then that project upgrade for the ipad for two specific device. and run in ipad. Then navigation bar is hide/show with same animation like iphone app does.

try this. May you get more idea.

Thanks,

MinuMaster



来源:https://stackoverflow.com/questions/8081725/setnavigationbarhidden-with-animation-not-working-on-ipad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!