Ajwhiteway Ajwhiteway - 1 year ago 183
Swift Question

iOS SWIFT Showing hidden view really slow

so I have a setup as such:

self.webView = WKWebView(frame: frame, configuration: WKWebViewConfiguration())
self.externView = UIView(frame: frame)
self.externWebView = WKWebView(frame: subFrame, configuration: WKWebViewConfiguration())
let StackView = UIStackView(frame: frame)

self.externView?.backgroundColor = UIColor.blackColor()

self.externView?.hidden = true

This creates the initial setup I want, this allows for 1 web view to act as the main one, which can launch and external one to render something else, that is initially hidden.

The problem I'm running into, is that from a worker thread I'm calling

WKExteralLoader.externView!.hidden = false;
WKExteralLoader.webView!.hidden = true;

which can take up to 30 seconds to take effect; however, its inverse is nearly instantaneous.

WKExteralLoader.webView!.hidden = false;
WKExteralLoader.externView!.hidden = true;

Any ideas what could cause this problem?


Answer Source

Run the hide/show code on the UI thread

 dispatch_async(dispatch_get_main_queue()) {
        WKExteralLoader.webView!.hidden = false;
        WKExteralLoader.externView!.hidden = true;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download