3

我试图消除在我的 iOS Phonegap 应用程序中加载本地页面之间的白色闪光。 我已经尝试了所有方法,但我仍然可以在页面加载之间看到白色。

我尝试使用 data-transition=none 使我的 html 背景变黑,并使 webView 背景颜色清晰。

我放了::

 NSLog(@"BEGIN EDIT - set webView to transparent");
[self.webView setBackgroundColor:[UIColor clearColor]];
[self.webView setOpaque: NO];
NSLog(@"END EDIT - set webView to transparent");

在 CDVInAppBrowser.m 、 CDVViewController.m 和 AppDelegate.m 中,但似乎没有任何效果!也许我将代码放在错误的位置。

请有人帮我摆脱页面加载之间的白色!

4

3 回答 3

0

I had the same problem when I made a mobile application with Phonegap. I don't know how do avoid these flashes but when you've built a simple app with only a few screens you could implement all your HTML documents into one file like:

<html>
    <body>
         <div class="page" id="page-1">
              Content of page one
         </div>
         <div class="page" id="page-2" style="display:none;">
              Content of page two
         </div>
         <div class="page" id="page-3" style="display:none;">
              Content of page three
         </div>
    </body>
</html>

Now you could switch between the contents of each container by making it visible/invisible for the user.

The idea behind this solution is that all of your app's content will get loaded once (at the beginning) and with jQuery you will switch between the content without these white flashes when the webbrowser has to render the new page the user has been redirected to.

This is a good solution only when your app does not contain too much contents.

于 2013-06-25T10:35:26.790 回答
0

就像我说的那样,在这种情况下,由于其复杂性,不可能将应用程序制作成单个文件,而且我不介意页面加载之间的白色闪烁是否为黑色,因为它们不会花费很长时间。这是我使用 Phonegap 2.8 for iOS 找到的解决方案:

在 CDVViewController.m

- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
    // Black base color for background matches the native apps
    theWebView.opaque = NO;
    theWebView.backgroundColor = [UIColor blackColor];
    //the rest of the code…

希望对其他人有用。

于 2013-06-25T14:48:17.023 回答
0

PhoneGap 加载可能会很慢。您可能需要使用闪屏 API 来显示和隐藏闪屏? http://docs.phonegap.com/en/2.8.0/cordova_splashscreen_splashscreen.md.html#Splashscreen

在上面的页面上,还要注意 iOS Quirk 部分。或者,您是否尝试过使用 jQuery Mobile 或 AngularJS 的单页应用程序?

于 2013-06-24T15:28:39.447 回答