Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- class ActivityViewcontroller: UIViewController, UIWebViewDelegate {
- @IBOutlet weak var webView: UIWebView!
- var url: String?
- override func viewDidLoad() {
- super.viewDidLoad()
- webView.loadRequest(URLRequest.init(url: URL.init(string: self.url!)!))
- }
- func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
- let path = request.url?.absoluteString
- if (path?.contains("_ACTION_CLOSE_WINDOW_"))! {
- self.navigationController?.popViewController(animated: true)
- return false
- }
- return true
- }
- func webViewDidFinishLoad(_ webView: UIWebView) {
- webView.stringByEvaluatingJavaScript(from: "window.alert = function(message) { window.location = message; }")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement