【问题标题】:ipad splash screen doesn't rotateipad闪屏不旋转
【发布时间】:2012-10-08 16:55:19
【问题描述】:

我希望能够将我的 ipad 上的初始屏幕旋转为左右横向。 我在我的 .plist 文件中启用了横向左右方向。我为 LandscapeRight 和 LandscapeLeft 添加了 4 个文件:

Default-LandscapeRight@2x~ipad.png
Default-LandscapeLeft@2x~ipad.png
Default-LandscapeRight~ipad.png 
Default-LandscapeLeft~ipad.png

虽然这不重要,但在我的 rootviewcontroller 中我有:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft); 
    return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
}

启动画面加载,但不旋转。 我做错了什么?

【问题讨论】:

  • 您可以为此使用自定义启动画面。
  • @SarafarazBabi 请详细说明。我认为定义横向左右启动画面是自定义启动画面
  • 我的意思是你可以为启动屏幕创建一个类并将其作为 rootviewcontroller 传递,1 或 2 秒后只需推动你的 homeview 控制器...并在启动屏幕类中管理 shouldautorotate...明白了吗?
  • @SarafarazBabi 好主意!谢谢!我想知道为什么我的方法不起作用?
  • 是否加载了正确的屏幕,或者您只是在旋转已经可见时缺少旋转?

标签: ios splash-screen


【解决方案1】:

据我所知,设备在 Splash Image 的持续时间内无法识别方向。这些 SPlash 图像 Def​​ault-LandscapeRight@2x~ipad.png Default-LandscapeLeft@2x~ipad.png Default-LandscapeRight~ipad.png 识别应用程序何时启动设备,然后设备采用适当的启动图像。 Default-LandscapeLeft~ipad.png.

如果你有兴趣,你可以做替代解决方案。这只是我的概念而已

1 为此目的创建 UIIMageView 并将其作为 SUBview 添加到 Window。

2 将 iamge 设置为该 UIIMageView。

3 设置睡眠方式 3-4 秒。像睡眠(4)。

4 调用 RootViewController 管理图像的方向。

像下面的方法 这是假设您在 AppDelegate 类中定义的方法将管理图像方向。

 -(void)checkOrientationforSplash:(UIInterfaceOrientation)interfaceOrentaion
    {
if (splashImageView.hidden==FALSE) {
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
    if (interfaceOrentaion==UIInterfaceOrientationPortrait|| interfaceOrentaion==UIInterfaceOrientationPortraitUpsideDown) {
        UIImage *image=[UIImage imageNamed:@"Default-Portrait.png"];
        splashImageView.frame=CGRectMake(0.0, 0.0, image.size.width, image.size.height);
        [splashImageView setImage:image];

    }
    else {
        UIImage *image=[UIImage imageNamed:@"Default-Landscape.png"];
        splashImageView.frame=CGRectMake(0.0, 20.0, image.size.width, image.size.height);
        [splashImageView setImage:image];
    }
       }

}

5 您可以在应用程序安装过程中管理该图像表单,即 RoortViewController。

6 在特定点删除该启动图像。

 -(void)removeSplash
   {
     [splashImageView setHidden:YES];
   }

希望对你有帮助。

【讨论】:

  • 这是个好主意!谢谢!顺便说一句,我的启动画面并没有以它不应该的方式启动! (即,如果我左右握持它是同一件事,它不会选择正确的飞溅)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-07-17
  • 1970-01-01
  • 2020-12-05
  • 1970-01-01
  • 2019-05-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多