Last active
March 10, 2020 12:15
-
-
Save zsajjad/32dc3d841bc8dfb2ef9bbb538c448a94 to your computer and use it in GitHub Desktop.
View Controller for Peekaboo iFrame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController, UIWebViewDelegate { | |
@IBOutlet weak var webView: UIWebView! | |
override func viewDidLoad() { | |
super.viewDidLoad(); | |
let url = URL(string: "https://*.peekaboo.guru"); // Replace * with your host | |
let request = URLRequest(url: url!) as URLRequest; | |
webView.loadRequest(request); | |
} | |
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool { | |
if navigationType == UIWebViewNavigationType.linkClicked { | |
print(request); | |
if (request.url?.host! == "*.peekaboo.guru"){ // Replace * with your host | |
return true | |
} else { | |
UIApplication.shared.open(request.url!, options: [:], completionHandler: nil) | |
return false | |
} | |
} | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment