I have a problem with a very simple iOS Swift project. The intention is for it to load a URL via UIWebView (eventually Crosswalk). My code is as follows:
import UIKit
import WebKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let myWebView:UIWebView = UIWebView(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height));
let url = NSURL (string: "https://www.www.google.com/");
let requestObj = NSURLRequest(URL: url!);
myWebView.loadRequest(requestObj);
self.view.addSubview(myWebView);
}
override func prefersStatusBarHidden() -> Bool {
return true
}
}
When it runs (iOS 9.3.4 on an iPod Touch 6th Gen 16b, if that matters), it displays an entirely white screen and sits there. After a short while, the Xcode output window displays:
error in __connection_block_invoke_2: Connection interrupted
Can anyone tell me what I've done wrong? Does the code look ok? Perhaps I set things up incorrectly? I've looked around and everyone has a different answer for it, but none of those seem to be the problem for me.
I know very little about iOS and Swift development so I apologize if this is a trivial problem, but I'd appreciate any help that can be given.
I dont know you add TransportSecurity to your info.plist or not if not add thus line of code to your project since from ios 9 apple change TransportSecurity then in your code you have 2 'www' in "https://www.www.google.com/" I fixed that and checked, it's work like charm
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>your.URL.come</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>