简体   繁体   中英

UIWebView is displaying white screen when loading in iOS

I have created only a single screen app in which when my app opens it directly redirects to the company's website url. SO i have created a single screen and uses web view and activity indicator but my app got rejected from apple store by providing a reason that white screen appears while loading web view.

// reason of rejection from app store ---

We discovered one or more bugs in your app when reviewed on iPhone and iPad running iOS 10.3.2 on Wi-Fi connected to an IPv6 network.

Specifically, the app launches to a blank white screen with no content loading.

I have tried a lot but for 2-3 seconds the white screen appears on screen. What to do please help. I am new to iOS.

// code for it

 import UIKit

 class ViewController: UIViewController, UIWebViewDelegate{


@IBOutlet weak var webView: UIWebView!

@IBOutlet weak var activityIndicator: UIActivityIndicatorView!


override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated) // No need for semicolon

    self.activityIndicator.startAnimating()
    self.activityIndicator.hidden = false

}

override func viewDidLoad() {
    super.viewDidLoad()

    self.webView.delegate = self

    let url = NSURL (string: "https://www.google.co.in/");
    let requestObj = NSURLRequest(URL: url!);
    webView.loadRequest(requestObj);


    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func webViewDidStartLoad(webView: UIWebView) {

  //        self.activityIndicator.startAnimating()
//        self.activityIndicator.hidden = false

}

func webViewDidFinishLoad(webView: UIWebView) {
    self.activityIndicator.stopAnimating()
    self.activityIndicator.hidden = true
}

}

When webview is loading content and somehow any js take time to load webview will display white screen until it complete to load that js. Check you url to browser and monitor which is the thing taking too much load time

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM