My app has a Terms & Conditions page. It is visible first time after app install. After accept terms it never shows to user.
I have make Launch image for first page, not for terms page. But it should be not standard for first time after app install.
So how I can use 2 launch image based on condition?
If I set Portrait mode only for my app (for both iPhone and iPad), Apple will reject that?
I solved this this way:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// ... stuff
if( [defaults objectForKey:@"GTCAccepted"] )
{
[self performSelector:@selector(gtcAccepted)]; //
}
else
{
GTCViewController* gtcViewController; // where GTCViewController is a normal UIViewController
//universal app
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
gtcViewController = [[GTCViewController alloc] initWithNibName:@"GTCViewController-iPad" bundle:nil];
else
gtcViewController = [[GTCViewController alloc] initWithNibName:@"GTCViewController" bundle:nil];
[window setRootViewController:gtcViewController]; // also can show as modal VC
[gtcViewController release];
// if accepted, set [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"GTCAccepted"]; in the GTCViewController
}
}
and to your 2 launch images...
try this code after accepting the GTC
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"GTCAccepted"];
NSURL *path2 = [[NSBundle mainBundle] URLForResource:@"Default-568h@2x_2" withExtension:@"png"];
NSURL *path = [[NSBundle mainBundle] URLForResource:@"Default-568h@2x" withExtension:@"png"];
[[NSFileManager defaultManager] removeItemAtURL:path error:nil]; // permission denied
if([[NSFileManager defaultManager] copyItemAtURL:path2 toURL:path error:nil])
{
NSLog(@"startItem replaced!");
}else
{
NSLog(@"oh oh... item not replaced!");
}
UPDATE:
Code doesn't work on device, see permission denied on delete
By the way, if you run in always on simulator starting with Xcode, you will override this every time you run. and here you have no chance to change the image before the app starts.