Reputation: 175
I'm trying to experiment with web view by using swift. I created a simple Xcode project, placed a web view within my application interface and connected it to my app delegate.swift with an outlet called "myview". By executing
self.myview.mainFrameURL = "http://www.google.com"
from within applicationDidFinishLaunching(), I would expect the Google's homePage to be loaded. However, this doesn't happen: the web view does not show anything. What am I doing wrong?
Upvotes: 1
Views: 1734
Reputation: 15422
1) Add the NSAppTransportSecurity in your plist https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/
2) check in your project settings that "Sandbox" is enabled and that internet connections are allowed
Upvotes: 3
Reputation: 175
After digging into the console logs, I found the solution to my problem. I'm not sure if I can share it though, since I'm using a beta OS X version and this restriction could have been introduced to improve apps' security, even if from what I can see it can be disabled.
Upvotes: 0
Reputation: 34945
You will have to call loadRequest()
to make it load a page.
So basically:
[self.myWebView loadRequest: [NSURLRequest requestWithURL:
[NSURL URLWithString: @"http://www.google.com"]]]
Upvotes: 0