ios - 在 iPhone 中隐藏状态栏,但在 iPad 中没有

标签 ios

我正在构建一个通用的 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/

相关文章:

ios - 如何能够在 Storyboard 中使用框架中的 UI 组件?

iphone - 存档应用程序时,Xcode 认为我的 Icon@2x.png 适用于 iPad 而不是 iPhone 4

javascript - 使用 Cordova 在 iOS 中显示带有外部源的图像

ios - 如何在 xcode 4 中部署 gdata-objectivec-client 库

ios - 我正在尝试安装 `VLCKit' pod 文件

ios - CNContactPickerViewController [CNUI ERROR] 调用服务时出错 - 无法与辅助应用程序通信

ios - 容器比例 swift 4

ios - 从 View Controller 调用应用程序委托(delegate)方法

ios - 具有动态内容的分页滚动

iphone - 我如何从 iphone 中删除 coredata