This is probably something easy for some expert, so. the thing is theres no WKWebView in Xcode visual interface for storyboard use, as opposed to UIWebview, so it has to be created programmatically . im using a nav controller for my whole app.
I created a VIEW in story board and used auto layout to constraint 0,0,0,0. so will like to add the WKWebView to that view "Daview". as a subview and fill it completely . i can't seem to figure it out.
Please take a look at the code Below
class ViewController2: UIViewController ,WKNavigationDelegate {
@IBOutlet weak var navigation: UINavigationItem!
@IBOutlet var daview: UIView!
var restWeb: WKWebView?
@IBOutlet var BottomView: UIView!
// var ActivityIndicator = UIActivityIndicatorView()
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(true)
println(" daview bounds in VIEWDIDAPPEAR is \(self.daview.bounds) y Frame \(self.daview.frame)")
restWeb!.bounds = daview.bounds
}
override func viewDidLoad() {
super.viewDidLoad()
/* Create our preferences on how the web page should be loaded */
let preferences = WKPreferences()
preferences.javaScriptEnabled = true
/* Create a configuration for our preferences */
let configuration = WKWebViewConfiguration()
configuration.preferences = preferences
/* Now instantiate the web view */
restWeb = WKWebView(frame: self.daview.bounds, configuration: configuration)
let urlString = "http://www.google.com"
println("EL DETAIL URL es \(urlString)")
if let theWebView = restWeb {
println("Existe restWeb")
let urlRest = NSURL(string:urlString)
let requestRest = NSURLRequest(URL: urlRest!)
theWebView.loadRequest(requestRest)
theWebView.allowsBackForwardNavigationGestures = true
theWebView.navigationDelegate = self
self.daview.addSubview(theWebView)
}
} // finish viewdidload