Question

When launching an iOS application, the screen jumps from the Default.png into the interface. For a current project, I'd like to fade in from that Default.png into the app's interface. Is there a good way to do this?

Was it helpful?

Solution

I took a bit of rooster117 and runmad's answers, and this is what I came up with.

Add a UIImageView to the first UIViewController's properties:

@interface DDViewController : UIViewController {
   ...
    UIImageView *coverImageView;
}

...

@property (nonatomic, retain) UIImageView *coverImageView;

Then, for the "home screen" of the iPad app, I call the following:

- (void)viewDidLoad
{
    [super viewDidLoad];

    ...

    coverImageView = [[UIImageView alloc] init];
}

-(void)viewWillAppear:(BOOL)animated {
    UIImage *defaultImage;   
    if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
        NSLog(@"Landscape!");
        defaultImage = [UIImage imageNamed:@"Default-Landscape.png"];
    } else {
        NSLog(@"Portrait!");
        defaultImage = [UIImage imageNamed:@"Default-Portrait.png"];
    }

    coverImageView = [[UIImageView alloc] initWithImage:defaultImage];
    [self.view addSubview:coverImageView];

}

-(void)viewDidAppear:(BOOL)animated {
    //Remove the coverview with an animation
    [UIView animateWithDuration:1.0f animations:^(void) {
        [self.coverImageView setAlpha:0.0];
    } completion:^(BOOL finished){
        [coverImageView removeFromSuperview];
    }];
}

OTHER TIPS

Yeah this isn't that hard to do. I accomplish this by making an image view with the default image and just animating it out. Something like this (put in the viewDidLoad of the first view controller):

_coverImage = [UIImage imageNamed:@"Default.png"];
}

[self.view addSubview:_coverImage];

[UIView beginAnimations:@"FadeOutCover" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(removeAndDeleteCover)];

[_coverImage setAlpha:0.0f];

[UIView commitAnimations];

then implement removeAndDeleteCover and do:

[_coverImage removeFromSuperview];

Hope that helps and if you need it to work for the iPad as a universal app you will have to check for that case and add the right default image.

Someone made a control for it on cocoacontrols.com

Here is the link for it: http://cocoacontrols.com/platforms/ios/controls/launchimagetransition

Expanding on rooster117's answer, you'll want to properly load your final "landing place", that is the view controller you want the user to actually interact with, before dismissing the "splash screen" view controller. This is very important for apps that load data from the network.

I seem to have done this in ios7 this way, think it should also work with 6 ?

https://stackoverflow.com/a/19377199/1734878

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top