Skip to content

Instantly share code, notes, and snippets.

@zsajjad
Last active March 10, 2020 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zsajjad/32dc3d841bc8dfb2ef9bbb538c448a94 to your computer and use it in GitHub Desktop.
Save zsajjad/32dc3d841bc8dfb2ef9bbb538c448a94 to your computer and use it in GitHub Desktop.
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