0

我想使用自定义启动画面,所以我在我的应用程序委托中执行此操作

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

    // Override point for customization after application launch.

    homeNavigationController = [[UINavigationController alloc] init];
    homeNavigationController.navigationBarHidden = NO;

    [homeNavigationController pushViewController:viewController animated:NO];

    // Add the view controller's view to the window and display.
    [window addSubview:homeNavigationController.view];
    [window makeKeyAndVisible];

    [self animateSplash];

    return YES;
}

- (void)animateSplash {

    CGRect cgRect = [[UIScreen mainScreen] bounds];
    CGSize cgSize = cgRect.size;

    // set default portrait for now, will be updated if necessary
    NSString *imageName = @"splash_screen.png";
    CGRect imageFrame = CGRectMake( 0, 0, cgSize.width, cgSize.height );

    imageStage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
    imageStage.frame = imageFrame;


    [window addSubview:imageStage];
    [window bringSubviewToFront:imageStage];

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDelay:2];
    [UIView setAnimationDuration:3.0f];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:window cache:YES];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];

    imageStage.alpha = 0.0f;

    [UIView commitAnimations];
}

- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {

    // remove and clean up splash image view
    [imageStage removeFromSuperview];
    [imageStage release];
    imageStage = nil;

}

这项工作正常,但由于我的应用程序在横向(主页按钮右侧)模式下启动,我的启动图像方向设置不正确。

4

2 回答 2

1

只需使用旋转的图像以在您的方向上看起来正确。

如果您出于某种原因真的想在代码中执行此操作,请查看如何将 UIImage 旋转 90 度?用于旋转 UIImage 的不同方法。

于 2012-04-10T20:06:08.897 回答
0

你需要告诉 iOS 你想在横向模式下启动你的应用程序。您可以按照 Apple此处的指示来实现此目的。

于 2012-04-10T20:07:59.507 回答