Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
View Controller for Peekaboo iFrame
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