0
我在我的應用程序中通過WebView加載html字符串。目前的問題是,當我的WebView加載包含另一個鏈接的內容,並且當用戶點擊該鏈接時,新視圖不會在我的應用程序中打開 - 它會在默認瀏覽器中打開。我如何在WebView中打開該鏈接?這裏是我的代碼:如何在webview中打開鏈接,如果它在webview中(swift)
override func viewDidLoad() {
super.viewDidLoad()
self.edgesForExtendedLayout = UIRectEdge.None
SVProgressHUD.show()
//EZLoadingActivity.show("أرجو الإنتظار", disableUI: true)
self.automaticallyAdjustsScrollViewInsets = false
self.navigationController!.navigationBar.tintColor = UIColor.whiteColor()
self.navigationController!.navigationBar.barStyle = UIBarStyle.Black
self.navigationController!.navigationBar.tintColor = UIColor.whiteColor()
let logo = UIImage(named: "toolbar_icon3")
let imageView = UIImageView(image:logo)
self.navigationItem.titleView = imageView
myweb.loadHTMLString(webviewurl, baseURL: nil)
}
的Android允許做它:
public boolean shouldOverrideUrlLoading(WebView view, String url)
但在iOS上,我們如何才能做到這一點?
他們應該 除非你重寫'shouldStartLoadWithRequest',否則默認是在webview中打開的。請爲您的「有時」案例提供一些示例鏈接 – zcui93