【问题标题】:Cordova iOS launch image changes while app is loading加载应用程序时 Cordova iOS 启动图像更改
【发布时间】:2014-08-07 10:19:49
【问题描述】:

我已在 Resources/splash 文件夹中使用正常命名方案(Default~ipad.png、Default-Portrait@2x~ipad.png 等)设置了我的启动图像/启动画面。我没有设置任何 UILaunchImage* plist 条目。

当我在 iPad2 上启动我的 Cordova 应用程序时,它会立即加载我的一张启动图像。几秒钟后(当 org.apache.cordova.splashscreen 插件开始运行时,从我在日志中看到的内容),启动图像会改变,通常会改变为不同的分辨率,因此整个图像会发生变化。在那之后,图像保持原样,直到我调用 navigator.splashscreen.hide()。这也发生在 iPhone4 上。

同样,启动画面会在应用程序打开时立即显示,几秒钟后切换,页面完成加载(根据控制台)大约 5 秒钟,然后 navigator.splashscreen.hide() 在我的 ready( ) 事件。

在我看来,Xcode 可能会默认选择我的一张图片作为启动图片,然后当 Cordova 闪屏插件与其他插件一起加载时,它会选择另一张图片。我最初确实得到了一个黑色闪光,并且找不到“Default.png”的控制台错误,所以我在启动图像中添加了一个“Default~ipad.png”。我原以为它会为 ipad 使用纵向或横向图像,但插件似乎只有在 CDV_IsIPad() 和 isOrientationLocked 时才会这样做。

我什至尝试将 Resources/splash 中的所有图像恢复为默认的 Cordova 启动图像。当我这样做时,Cordova 启动图像会在应用程序加载时立即显示,几秒钟后,当 Cordova 启动画面插件加载时,启动图像会更改为我的启动图像之一,然后在 navigator.splashscreen.hide() 上消失。发生这种情况时,我无法在任何地方找到我从项目中删除的启动图像的任何引用;不在 Resources/splash 或 plist 中。很奇怪。

有什么想法为什么cordova s​​plashscreen插件会改变启动画面,或者我应该做些什么来解决这个问题?

【问题讨论】:

  • 可能想要设置您的 plist 条目。 iOS launchImage(第一个)与 cdv splashscreen(第二个)不同,因此您需要将它们指向相同的资源。

标签: ios cordova splash-screen launchimage


【解决方案1】:

我最终查看了 Cordova Splashscreen 插件的拉取请求,只是想看看是否有人解决了这个问题。 Looks like they did!

src/ios/CDVSplashScreen.m

- } else if (CDV_IsIPad() && isOrientationLocked) {
-        switch (orientation) {
-            case UIInterfaceOrientationLandscapeLeft:
-            case UIInterfaceOrientationLandscapeRight:
-                imageName = [imageName stringByAppendingString:@"-Landscape"];
-                break;
-
-            case UIInterfaceOrientationPortrait:
-            case UIInterfaceOrientationPortraitUpsideDown:
-            default:
-                imageName = [imageName stringByAppendingString:@"-Portrait"];
-                break;

应该是

+    } else if (CDV_IsIPad()) {
+        if (isOrientationLocked) {
+            imageName = [imageName stringByAppendingString:(supportsLandscape ? @"-Landscape" : @"-Portrait")];
+        } else {
+            switch (orientation) {
+                case UIInterfaceOrientationLandscapeLeft:
+                case UIInterfaceOrientationLandscapeRight:
+                    imageName = [imageName stringByAppendingString:@"-Landscape"];
+                    break;
+
+                case UIInterfaceOrientationPortrait:
+                case UIInterfaceOrientationPortraitUpsideDown:
+                default:
+                    imageName = [imageName stringByAppendingString:@"-Portrait"];
+                    break;
+            }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多