shouldstartload

Prevent user from leaving website in Swift

妖精的绣舞 提交于 2019-12-11 23:33:10
问题 I want to create a WebView in an iPad-App, that displays a website. I want to prevent the user to click on links that link to other websites (e.g. Facebook, Twitter, ...) but he should be allowed to move around on the current website freely. How can I achieve this? I tried with: func webView(WebViewNews: UIWebView!, shouldStartLoadWithRequest request: NSURLRequest!, navigationType: UIWebViewNavigationType) -> Bool { let newWebsite:String = (request.URL?.path)! print(newWebsite) if newWebsite

Xcode, Swift; Detect hyperlink click in UIWebView

大憨熊 提交于 2019-12-04 01:30:37
问题 I made an iOS app with Xcode and Swift. I want to open specific hyperlinks in Safari browser, there others in the WebView itself. To reach this, I'll have to check when an hyperlinks gets clicked. This is the code I have so far: // // PushViewController.swift // App // // import UIKit class PushViewController: UIViewController, UIWebViewDelegate { @IBOutlet var openpushmessage: UIWebView! var weburl:String = "http://www.example.com" override func viewDidLoad() { super.viewDidLoad() let url: