setNavigationBarHidden动画无法在iPad上运行 [英] setNavigationBarHidden with animation not working on iPad

查看:55
本文介绍了setNavigationBarHidden动画无法在iPad上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户单击按钮时,我在我的应用程序中使用以下代码:

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

外观通常在iPhone上具有动画效果,但在iPad上则没有动画效果.你知道为什么吗?

解决方案

最好的解决方法是将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];
}

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 ?

解决方案

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

这篇关于setNavigationBarHidden动画无法在iPad上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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