我正在构建一个通用的 iOS 应用程序。我想隐藏 iPhone 中的状态栏,但我想在 iPad 中显示状态栏。我如何做到这一点。如果我在 info.plist 中将“状态栏最初隐藏”属性设置为"is",则它在 iPhone 和 iPad 中都将被隐藏。
最佳答案
将以下代码添加到方法 - (BOOL)application:didFinishLaunchingWithOptions:
在您的 AppDelegate 类中。
if((void *)UI_USER_INTERFACE_IDIOM() != NULL && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
//the device is iPad
//no need of this anyhow since it is not hidden by default
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
}
else
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
}
关于ios - 在 iPhone 中隐藏状态栏,但在 iPad 中没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8939903/