简体   繁体   中英

Hiding status bar in iPhone but not in iPad

I am building a universal iOS app. I want to hide the status bar in iPhone but I want to show the status bar in iPad. How do I achieve this. If I set the "Status bar is initially hidden" property to "YES" in info.plist, it is getting hidden in both iPhone and iPad.

Add the following code to the method - (BOOL)application:didFinishLaunchingWithOptions: in your AppDelegate class.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM