3

Right now it looks like that one has to set the launch image file name (launchimage.xib, for example) for "Launch screen file" field in build setting in order for that launchimage.xib to display. Is it possible to instead:

  • dynamically load the launch image, and/or
  • associate an action with the launch image?
Mark Amery
  • 143,130
  • 81
  • 406
  • 459
NSCoder
  • 255
  • 5
  • 15

2 Answers2

8

I believe launch image cannot be loaded dynamically. However you can access the launch images you have added into your app using the following code. Also you can check if it matches to your device scale and size.

NSArray *allPngImageNames = [[NSBundle mainBundle] pathsForResourcesOfType:@"png"
                                    inDirectory:nil];

for (NSString *imgName in allPngImageNames){
// Find launch images
if ([imgName containsString:@"LaunchImage"]){
    UIImage *img = [UIImage imageNamed:imgName]; //-- this is a launch image

    // Has image same scale and dimensions as our current device's screen?
    if (img.scale == [UIScreen mainScreen].scale && CGSizeEqualToSize(img.size, [UIScreen mainScreen].bounds.size)) {
        NSLog(@"Found launch image for current device %@", img.description);
    }
  }
}

However I do not believe this would help you much

Ganesh Somani
  • 2,280
  • 2
  • 28
  • 37
  • Thanks @Ganesh---I was looking for dynamic launching options, i.e., if a file name is passed to the app, it should load that filename.xib instead of the default launch image. – NSCoder Mar 18 '15 at 06:59
  • That is not possible programtically. There are other question with similar answers http://stackoverflow.com/questions/7015532/dynamically-change-launch-image-in-ios and http://stackoverflow.com/questions/23637378/can-i-choose-my-launch-image-programmatically – Ganesh Somani Mar 18 '15 at 12:25
1

The launch image (or storyboard) is handled by the app launcher, not by the app itself. So I see no way to load a dynamic launch image nor attach an action. The documentation at https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/launch-screen/ does not provide any options for your launch screen besides using a storyboard or static images.

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
OliverD
  • 864
  • 7
  • 8