Remove iPad status bar (iPhone App)

Discussion in 'iOS Programming' started by xArtx, Oct 2, 2013.

  1. xArtx macrumors 6502a

    Joined:
    Mar 30, 2012
    #1
    Hi Guys,
    Is it possible for the App to remove the status bar when running on iPad,
    when the App is not a Universal App (compiled only for iPhone) ?

    Something tells me any iPad settings in a plist will be ignored for an iPhone App.

    It's a very retro sprite game, where doing the iPad resolution wouldn't really have
    any benefit, except perhaps this.
    Cheers, Art.
     
  2. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #2

    You use the idiom call to tell if your app is running as an iPad app or iPhone app. There are other calls that let you tell what kind of hardware you are running on. (Don't remember the details off the top of my head.)

    You should be able to write code that figures out what device it's running on and then hides the status bar if it determines that it's running on an iPad, even though you are running as an iPhone app.
     
  3. xArtx thread starter macrumors 6502a

    Joined:
    Mar 30, 2012
    #3
    I can already see if it's an iPad
    Code:
        NSString *deviceType = [UIDevice currentDevice].model;
        if([deviceType isEqualToString:@"iPhone"]) {} // it's an iPhone
        if([deviceType isEqualToString:@"iPad"]) {} // it's an iPad
    
    (omitting other device types)...
    The way I hide the status bar is in Xcode's interface for the project,
    which I think is linked to the setting in the plist file,
    but the iPad is ignoring that.
    Is there a way to do it at run time?

    edit,,
    Code:
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
    
    This could be the ticket.


     
  4. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #4

    That or the UIApplication method setStatusBarHidden:withAnimation:
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    I would recommend using something like this:
    Code:
    if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
     
  6. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #6
    No, that tells you if you are running in iPad or iPhone mode.

    In the OPs case of an iPhone app that's running in iPhone mode on an iPad, the idiom call will return UIUserInterfaceIdiomPhone, which is not what he wants.

    His code that checks the device type is the correct answer in this case.
     
  7. xArtx thread starter macrumors 6502a

    Joined:
    Mar 30, 2012
    #7
    Only problem is it is only the iPhone that is listening to the programatic
    way to turn the status bar off.
    I went to put the line in ly app delegate, and it was already there.
     
  8. xArtx thread starter macrumors 6502a

    Joined:
    Mar 30, 2012
    #8
    I think they've thought beyond it, when an iPhone App is running on iPad,
    the iPad is using the 3.5 inch screen, and even in 2x mode, they know there
    is always room left for the iPad status bar.

    Also, if you run an iPhone App that normally wants to show the status bar,
    I wonder if they had to do any fiddling to handle where the status bar would
    be shown on the iPhone screen within the iPad.
     

Share This Page