Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 launch image (splash screen) fades out

On iOS 7, launch images fade out instead of disappearing immediately when the app is loaded.

Is there any setting to prevent this launch image fade out animation? I need it to disappear immediately just like in the iOS 6 and earlier.

Edit for answers:

Yes, it is possible to add the splash image as a UIImageView to the top window and hide it after splash fade animation is completed. But this causes a delay of 0.4 seconds which I'm trying to avoid.

like image 808
erkanyildiz Avatar asked Aug 22 '13 09:08

erkanyildiz


People also ask

What is difference between splash screen and launch screen?

Splash Screen is the very first screen the user sees when they open up an app on a mobile device. It's the very first chance of creating a positive impact on the users. It appears while the app is loading when the user has just opened up the app. Many times the Splash screen is called a launch screen.

What size should a splash screen be iOS?

768 x 1024 pixels (standard resolution)

Is splash screen mandatory iOS?

No, it is not required to set a launch image.


4 Answers

I have managed to do that in the AppController. Just place this code right after the creation of the glView

    UIImage* image = [UIImage imageNamed:[self getLaunchImageName]];
if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)])
{
    float screenScale = [[UIScreen mainScreen] scale];
    if (screenScale > 1.)
        image = [UIImage imageWithCGImage:image.CGImage scale:screenScale orientation:image.imageOrientation];
}
UIImageView *splashView = [[UIImageView alloc] initWithImage:image];
[viewController.view addSubview:splashView];
[splashView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.1f];

It is easy. Just get the launch image and make it disappear after a delay. You will need the getLaunchImage code (based on this comment, not tested with iPhone 6 nor 6 plus)

    -(NSString*)getLaunchImageName
{

    NSArray* images= @[@"LaunchImage.png",
                       @"[email protected]",
                       @"[email protected]",
                       @"[email protected]",
                       @"[email protected]",
                       @"LaunchImage-700-Portrait@2x~ipad.png",
                       @"LaunchImage-Portrait@2x~ipad.png",
                       @"LaunchImage-700-Portrait~ipad.png",
                       @"LaunchImage-Portrait~ipad.png",
                       @"LaunchImage-Landscape@2x~ipad.png",
                       @"LaunchImage-700-Landscape@2x~ipad.png",
                       @"LaunchImage-Landscape~ipad.png",
                       @"LaunchImage-700-Landscape~ipad.png",
                       @"[email protected]",
                       @"[email protected]",
                       @"[email protected]",
                       ];

    UIImage *splashImage;

    if ([self isDeviceiPhone])
    {
        if ([self isDeviceiPhone4] && [self isDeviceRetina])
        {
            splashImage = [UIImage imageNamed:images[1]];
            if (splashImage.size.width!=0)
                return images[1];
            else
                return images[2];
        }
        else if ([self isDeviceiPhone5])
        {
            splashImage = [UIImage imageNamed:images[1]];
            if (splashImage.size.width!=0)
                return images[3];
            else
                return images[4];
        }
        else if ([self isDeviceiPhone6])
        {
            splashImage = [UIImage imageNamed:images[1]];
            if (splashImage.size.width!=0)
                return images[13];
            else
                return images[14];
        }
        else
            return images[0]; //Non-retina iPhone
    }
    else if ([[UIDevice currentDevice] orientation]==UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown)//iPad Portrait
    {
        if ([self isDeviceRetina])
        {
            splashImage = [UIImage imageNamed:images[5]];
            if (splashImage.size.width!=0)
                return images[5];
            else
                return images[6];
        }
        else
        {
            splashImage = [UIImage imageNamed:images[7]];
            if (splashImage.size.width!=0)
                return images[7];
            else
                return images[8];
        }

    }
    else
    {
        if ([self isDeviceRetina])
        {
            splashImage = [UIImage imageNamed:images[9]];
            if (splashImage.size.width!=0)
                return images[9];
            else
                return images[10];
        }
        else
        {
            splashImage = [UIImage imageNamed:images[11]];
            if (splashImage.size.width!=0)
                return images[11];
            else
                return images[12];
        }
    }
}

-(BOOL)isDeviceiPhone
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        return TRUE;
    }

    return FALSE;
}

-(BOOL)isDeviceiPhone4
{
    if ([[UIScreen mainScreen] bounds].size.height==480)
        return TRUE;

    return FALSE;
}


-(BOOL)isDeviceRetina
{
    if ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] &&
        ([UIScreen mainScreen].scale == 2.0))        // Retina display
    {
        return TRUE;
    }
    else                                          // non-Retina display
    {
        return FALSE;
    }
}


-(BOOL)isDeviceiPhone5
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && [[UIScreen mainScreen] bounds].size.height==568)
    {
        return TRUE;
    }
    return FALSE;
}

-(BOOL)isDeviceiPhone6
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && [[UIScreen mainScreen] bounds].size.height>568)
    {
        return TRUE;
    }
    return FALSE;
}
like image 176
Alex R. R. Avatar answered Oct 21 '22 09:10

Alex R. R.


In iOS 7, the splash screen fade-transitions from the splash image to your first UIView. If that UIView looks identical to the splash screen, you see no fade. The problem is that Cocos2D's initial view is pure black.

Unfortunately, the only way I found to resolve this was to actually add a UIImageView identical to the splash image for a second, then remove it once Cocos2D started drawing.

In CCDirectorIOS (or your subclass):

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_WIDESCREEN (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height > 567.0f)
static const NSInteger tempSplashViewTag = 87624;

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    NSString *spriteName = IS_IPAD ? @"Default-Landscape" : IS_WIDESCREEN ? @"Default-568h" : @"Default";
    UIImageView *splashView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:spriteName]];
    splashView.tag = tempSplashViewTag; 
    [self.view addSubview:splashView];

    [self startAnimation];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC));
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        UIView *splashView = [self.view viewWithTag:tempSplashViewTag];
        [splashView removeFromSuperview];
    });
}
like image 4
Patrick Avatar answered Oct 21 '22 10:10

Patrick


I had the same problem developing an app with Cocos2D-x and having my main window and OpenGL content initialize in

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

Instead I moved it to the method

- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

and now it doesn't "fade" any more. Note the will instead of did. This method is available on iOS6 and higher however, so if you want your app to be compatible with iOS5.x and lower you can just do a preprocessor version check for < __IPHONE_6_0 and use the "didFinishLaunching" method, since there it wasn't even an issue.

like image 3
thgc Avatar answered Oct 21 '22 10:10

thgc


If that is really your code, you probably have a typo in the image name. (If not, let us know what "not working" means.)

Also, the splash screen doesn't normally come up every applicationDidBecomeActive:. didFinishLaunchingWithOptions: is the time you know that you have been launched and the splash screen had been shown on your behalf.

-(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [UIView animateWithDuration:0.2
                          delay:0
                        options: UIViewAnimationCurveEaseIn // change effect here.
                     animations:^{
                        self.window.viewForBaselineLayout.alpha = 0; // and at this alpha
                     }
                     completion:^(BOOL finished){
                     }];

    return YES;
}
like image 2
bLacK hoLE Avatar answered Oct 21 '22 09:10

bLacK hoLE