G
G
gents2016-05-17 15:33:14
macOS
gents, 2016-05-17 15:33:14

How to follow external link in WebView osx Swift?

Hello, I'm writing my first application in Swift.
There is a WebView where I open the site:

let defaultURL = "https://yandex.ru"

override func viewDidLoad() {
    self.EasyW.frameLoadDelegate = self
    self.EasyW.policyDelegate = self
    self.EasyW.mainFrame.loadRequest(NSURLRequest(URL: NSURL(string: defaultURL)!))

}

Everything works fine, but when you click on an external link, nothing happens( How can I open an external link in the default browser?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Globak, 2016-05-26
@maximglobak

you need to bind an action to a button (IBAction) and write inside the function

let defaultURL = NSURL(string: "https://yandex.ru")!
UIApplication.sharedApplication().openURL(defaultURL!)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question