The key to this is that the Info.plist
file contains information on which splash image to use. This method below will find that name from the Info.plist
, and then you'll just have to query it from [UIImage imageNamed:@""]
method.
- (NSString *)splashImageNameForOrientation:(UIInterfaceOrientation)orientation {
CGSize viewSize = self.view.bounds.size;
NSString* viewOrientation = @"Portrait";
if (UIDeviceOrientationIsLandscape(orientation)) {
viewSize = CGSizeMake(viewSize.height, viewSize.width);
viewOrientation = @"Landscape";
}
NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
for (NSDictionary* dict in imagesDict) {
CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
return dict[@"UILaunchImageName"];
}
if (imagesDict.count > 0) {
return [imagesDict firstObject][@"UILaunchImageName"];
}
return nil;
}