2
我是很新的WKWebView和我這個問題,在我目前看來並沒有改變從JavaScript調用windows.open當看到下面掙扎......爲什麼在調用window.open時,createWebviewWithConfiguration不會更改顯示的視圖?
function logo_click() {
window.open(some_valid_url);//url is valid www.google.com for example
}
我敢肯定,這個功能被擊中因爲我使用Safari Tech Preview加強了它。而我甚至讓斷點在我createWebviewWithConfiguration()在Xcode OBJ-C函數被調用時logo_click,
-(WKWebView*)webView:(WKWebView)webView createWebViewWithConfiguration:(nonnull WKWebViewConfiguration)inConfig forNavigationAction:(nonnull WKNavigationAction)navigationAction windowFeatures:(nonnull WKWindowFeatures)windowFeatures
{
_webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:inConfig];
if (!navigationAction.targetFrame.isMainFrame) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[self.webView loadRequest:navigationAction.request];
//[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.google.com"]]];
}
return _webView;
}
我甚至嘗試硬編碼google.com,看看它是否可以從那裏導航,但我的觀點顯示仍然是前一個。我已經檢查了教程
iphonedevsdk.com/forum/iphone-sdk-development/122635-wkwebview-wont-open-external-links.html
,但我的看法仍然沒有改變。我可能會錯過什麼?