SHARE
TWEET

Untitled

a guest Mar 20th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import UIKit
  2.  
  3. class ActivityViewcontroller: UIViewController, UIWebViewDelegate {
  4.  
  5.     @IBOutlet weak var webView: UIWebView!
  6.     var url: String?
  7.  
  8. override func viewDidLoad() {
  9.     super.viewDidLoad()
  10.     webView.loadRequest(URLRequest.init(url: URL.init(string: self.url!)!))
  11. }
  12.  
  13. func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
  14.     let path = request.url?.absoluteString
  15.     if (path?.contains("_ACTION_CLOSE_WINDOW_"))! {
  16.         self.navigationController?.popViewController(animated: true)
  17.         return false
  18.     }
  19.     return true
  20. }
  21.  
  22. func webViewDidFinishLoad(_ webView: UIWebView) {
  23.     webView.stringByEvaluatingJavaScript(from: "window.alert = function(message) { window.location = message; }")
  24.     }
  25. }
RAW Paste Data
Top