Splash Screen Problem

£可爱£侵袭症+ 提交于 2019-12-04 20:40:16

Just add a view with uiimageview and set its image to default.png. load this view in the beginning. After you splash screen unloads this shuld be the you view and then flip it.

You can't do the flip transition with default.png , try to add a view with that image in window and apply transition to that view.

You can't give Transition style to splash screen using deafult.png image.Create another UIViewController with splash image, just dismiss this view controller with required Transition style and time.

After the splash screen loads.Just replace it with your new UIImageView and set flip transition.

all the folks above are correct about two things:

i. You can't add transition to the Default.png ii. You need to add UIView (or UIImageView) in order to add transition.

Here's some sample code for you to use:

AppDelegate.h

@interface AppDelegate: .... {
...
@property (strong, nonatomic) UIImageView *splashView;
...
@end

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:   (NSDictionary *)launchOptions
{
// fade Default.png into next screen
self.splashView = [[UIImageView alloc] initWithFrame:
                   CGRectMake(0, 0, self.window.frame.size.width,        self.window.frame.size.height)];

// get the right image (does not work on simulator)
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 
    self.splashView.image = [UIImage imageNamed:@"Default.png"];
else {
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation]))
        self.splashView.image = [UIImage imageNamed:@"Default-Landscape.png"];
    else
        self.splashView.image = [UIImage imageNamed:@"Default-Portrait.png"];
    [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
}
if (self.splashView) {
    [self.window.rootViewController.view addSubview:self.splashView];
    [self.window.rootViewController.view bringSubviewToFront:self.splashView];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.window cache:YES];
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
    self.splashView.alpha = 0.0;
    [UIView commitAnimations];
}
return YES;

}

Comments

Notice how I have used setAnimationTransition:UIViewAnimationTransitionNone above. Also, you can use delegate to customize (remove the splashView from super view basically) once done.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!