Reputation: 996
I want to change the launch image of my app each time I open it. I've searched on Google and I've found two approaches:
Set my launch image name in the plist config file, and replace the image file each time.
Delete the launch image property in the plist each time the app launches, display another imageview or uiview, and change the image of the imageview;
The first way, some people said that Apple might reject the app or it may not be approved. Is this likely to be the case?
The second way, it takes a long time after my app is configured and loaded and the app displays a black screen during the loading itself.
Upvotes: 5
Views: 4534
Reputation: 2069
I'd recommend you to do this in code, aka display a "virtual" launch screen of your own using UIImageView.
What you want to achieve is impossible, ipas (and thus their contents, including Info.plist) are signed when you archive your app. That means that any modification you make will break the signature, and so you'd need to resign it to make it executable again. The only way to achieve this is to sign your contents again and submit the app to the AppStore once more which kinda invalidates your argument.
Go for the UIImageView approach, I know it won't look that nice but it's the closest you can get given the constraints Apple's ecosystem imposes.
Upvotes: 7
Reputation: 12123
The simple answer is NO you are not allowed to do this. This is because the image that you would have to modify is Default.png
which is the launch image name which is located in the main bundle of the project, and it is not allowed to edit/amend/modify files in the main bundle of an iOS project.
This is because the contents of the main bundle are cryptographically (Think that's how it's spelt) signed as part of the Apple App store submission. So in modifying the contents within the main bundle could cause the application to stop running.
This also goes against the Apple submission guidelines.
Also Whilst some have suggested doing it through code with animation after it launches you will still need a launch image as it is part of the apple human interface guidelines. All apps must have a launch image.
The only time that you can have different launch images is when your basing it on device and/or retina display and/or orientation.
Here are some of the ones you can use.
Default.png
[email protected]
Default-568h.png or [email protected]
Default-Portait.png
[email protected]
Default~ipad.png
Default-Portait~ipad.png
Default@2x~ipad.png
etc
Upvotes: 4
Reputation: 50129
the launch image itself isn't changeable as it is in your bundle. the best way is to show a UIImageView as soon as you can.
that means: applicationDidFinishLaunching should just put up the window and an image view and schedule the real work later. Return YES ASAP -- that way, iOS will think your app has launched and show your window with the uiimageview
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// show the main window, overlay with splash screen + alpha dissolve...
UIImageView *splashScreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default.png"]];
[self.window addSubview:splashScreen];
[self.window makeKeyAndVisible];
// in the method do all you normally do
[self performSelector:@selector(delayedLaunch:) withObject:options afterDelay:0.1];
[UIView animateWithDuration:0.3 animations:^{splashScreen.alpha = 0.0;}
completion:(void (^)(BOOL)) ^{
[splashScreen removeFromSuperview];
}
];
return YES;
}
Upvotes: 2