Created
August 20, 2015 18:31
-
-
Save wfortin/bf7fd2c1798429f0a8fa to your computer and use it in GitHub Desktop.
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 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