arefin
arefin

Reputation: 365

Multiple Launch image of iOS

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.

  1. So how I can use 2 launch image based on condition?

  2. If I set Portrait mode only for my app (for both iPhone and iPad), Apple will reject that?

Upvotes: 0

Views: 1437

Answers (2)

geo
geo

Reputation: 1791

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.

Upvotes: 0

Duc Nguyen
Duc Nguyen

Reputation: 168

  1. I think you should not using 2 launch image. If you want to check image based on condition, you can use a view controller to show, animation it and go to to next screen. Launch image only one. we can't access it.
  2. Only portrait for both iPhone and iPad will not reject.

Upvotes: 1

Related Questions