【问题标题】:Splash Screen Image's orientation is not correct启动画面图像的方向不正确
【发布时间】:2012-04-10 19:45:51
【问题描述】:

我想使用自定义启动画面,所以我在我的应用委托中这样做

- (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;

}

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

【问题讨论】:

  • 发帖前请阅读FAQ;您的特殊兴趣点:1. 代码格式,2. 使用页脚。
  • 肯定会这样做直到我是 StackOverflow 的新手 :( 下次会注意的。

标签: iphone objective-c ios uiimageview splash-screen


【解决方案1】:

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

如果您出于某种原因真的想在代码中执行此操作,请查看 How to Rotate a UIImage 90 degrees? 了解旋转 UIImage 的不同方法。

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 我已经在我的 plist 中说明了我的图像仍然没有随着屏幕正确旋转
    • 您是否设置了 LandscapeLeft 或 LandscapeRight?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-19
    • 2021-11-15
    • 2021-11-14
    相关资源
    最近更新 更多