gpt4 book ai didi

html - 如何从另一个 UIWebView 打开 UIWebView?

转载 作者:行者123 更新时间:2023-11-28 19:50:45 27 4
gpt4 key购买 nike

我的一个包含链接的 View Controller 底部有一个 Web View 。我想要做的是,当用户单击 Web View 中的一个链接时,它会打开一个 Web View ,该 View 占据屏幕,其中包含用户单击的页面内容。或者,当用户单击 Web View 中的其中一个链接时,用户将被带到 Safari 以显示链接的内容。有人知道怎么做吗?干杯。

enter image description here

上面是 Web View 的屏幕截图,其中包含用户可以单击的链接。

最佳答案

您可以使用 UIWebView 的委托(delegate) - webView:shouldStartLoadWithRequest:navigationType:。在加载每个 url 之前,它将调用以下委托(delegate) -

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

您将能够从请求中获取请求 url 并推送新的 View Controller 。

更多详情:https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIWebViewDelegate_Protocol/index.html#//apple_ref/occ/intfm/UIWebViewDelegate/webView:shouldStartLoadWithRequest:navigationType :

关于html - 如何从另一个 UIWebView 打开 UIWebView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29397395/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com