Skip to content

Instantly share code, notes, and snippets.

@wfortin
Created August 20, 2015 18:31
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 wfortin/bf7fd2c1798429f0a8fa to your computer and use it in GitHub Desktop.
Save wfortin/bf7fd2c1798429f0a8fa to your computer and use it in GitHub Desktop.
import UIKit
class ViewController: UIViewController, UIWebViewDelegate {
@IBOutlet var webView: UIWebView!
var AppUrl = "http://df15.coveodemo.com"
override func viewDidLoad() {
super.viewDidLoad()
self.webView.delegate = self;
loadDreamforceWebApp()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewDidAppear(animated: Bool) {
webView.frame = UIScreen.mainScreen().bounds
webView.center = self.view.center
}
func loadDreamforceWebApp() {
let requestUrl = NSURL (string: AppUrl)
let requestObj = NSURLRequest(URL: requestUrl!)
webView.loadRequest(requestObj)
}
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
if navigationType == UIWebViewNavigationType.LinkClicked {
if (request.URL!.host! == "df15.coveodemo.com"){
return true
} else {
UIApplication.sharedApplication().openURL(request.URL!)
return false
}
}
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment