-4

I am trying to create an iPhone app with two WKWebView, one for a header and one for a container. How can I create them?

I can't find any utility in Xcode/Interface Builder to create WKWebview instances. I can create a WebView which is of type UIWebView, but I can't call WkWebView methods on it and I can't conversion it to a WKWebview.

4

2 回答 2

1
var item = WKWebView()
item.frame = CGRectMake(0, 0,
        self.view.bounds.width, 200.)
self.view.addSubview(item)

item = WKWebView()
item.frame = CGRectMake(0, self.view.bounds.height-200.,
        self.view.bounds.width, 200.)
self.view.addSubview(item)

此代码添加WKWebViewself.view.

于 2014-12-10T15:55:30.773 回答
0
var item = WKWebView() 
item.frame = CGRectMake(0,0,self.view.bounds.width,self.view.bounds.height) 
var path = NSBundle.mainBundle().pathForResource("header", ofType:".html")
var url = NSURL.fileURLWithPath(path!) 
var request = NSURLRequest(URL:url!)
item.loadRequest(request) self.view.addSubview(item)
var item1 = WKWebView() 
item1.frame = CGRectMake(0, 50, self.view.bounds.width, self.view.bounds.height) 
var url1 = NSURL(string:"kinderas.com/") 
var req = NSURLRequest(URL:url1) 
item1.loadRequest(req) 
self.view.addSubview(item1) 
于 2014-12-11T06:53:38.193 回答