Loading an image in the Launch screen xib file?

Discussion in 'iOS Programming' started by MacMan988, Jan 3, 2015.

  1. MacMan988 macrumors 6502a

    Joined:
    Jul 7, 2012
    #1
    Hi,

    I have launch images designed for my app for various screen sizes. But I figured it out that Apple now recommends to use an XIB or a Storyboard file as the launch image. Is it possible to place a UIImageView in the XIB and load the correct image (with correct resolution for the device) in the UIImageView?
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Where does Apple recommend this? Perhaps you are confusing the launch image with the main interface.
     
  3. MacMan988 thread starter macrumors 6502a

    Joined:
    Jul 7, 2012
    #3
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    Yes, this is new with iOS 8. You can use a launch xib or launch storyboard. You specify this in the Launch Screen File setting in Xcode under Target > App Icons and Launch Images. If you support older OS versions you still need the launch images for those as before.

    @OP, there can be no code associated with the xib. I haven't done this for an image but I don't see why you can't have an image view in your xib and specify the image name to be an image from your bundle. Did you try that?

    I don't think you can adjust the image name from the app code but you should be able to specify a single image name in the xib.

    If your goal is to load the launch images that were used for iOS 7 into an image view that wouldn't make sense. Make your xib look like the first screen of your app. That's the point of it. It will adjust to the screen size and orientation of the device and look correct.

    I needed a table view with navbar. Doing this with a storyboard worked better than with a xib.
     
  5. waterskier2007 macrumors 68000

    waterskier2007

    Joined:
    Jun 19, 2007
    Location:
    White Lake, MI
    #5
    Yes, you can do this. I have done this with multiple applications. Include the image in your Images.xcassets (or whatever yours is named) and specify this image in Interface Builder
     
  6. Mascots macrumors 65816

    Mascots

    Joined:
    Sep 5, 2009
    #6
    This. I was going to say exactly what you said in your last line, but it's important to emphasize for others: Use a Storyboard, not a Nib, for your Launch Image if you want to correctly compensate for UINavigationBar's and Status Bars.
     
  7. MacMan988 thread starter macrumors 6502a

    Joined:
    Jul 7, 2012
    #7
    Thanks for all replies.

    I know that the Images.xcassets can be used to load the correct image based on the pixel density of the device. Is there any similar way to load versions of images based on resolution as well? (e.g: I have two background images for the iPhone 4S and iPhone 5 with two different resolutions and I want to load the correct one based on the device type).
     
  8. waterskier2007 macrumors 68000

    waterskier2007

    Joined:
    Jun 19, 2007
    Location:
    White Lake, MI
    #8
    When you have an image set you can specify different images based on the specific device size. Just set the "Devices" drop down to "Device Specific"

    See here: [​IMG]
     

Share This Page