Advertisement
Guest User

Untitled

a guest
Mar 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement