我目前使用 SafariViewController 作为我的应用内浏览器。当 URL 与正则表达式 /youtube\.com/
匹配时,我尝试自动加载 AVPlayerViewController
,而不是实际加载 YouTube 页面。
这可以通过 SafariViewController 实现吗?我查看了文档,但我的委托(delegate)方法没有执行任何与此相关的操作。我还可以将浏览器更改为 WKWebView 或其他浏览器,尽管这不太有利。
最佳答案
SFSafariViewController
旨在为您提供一种以最少的自定义方式呈现典型 Safari 体验的方法(如 SFSafariViewControllerDelegate
可用的自定义功能的稀疏性所示) >)。如果您想要进行更复杂的体验定制,您或多或少会陷入 WKWebView
的困境。 SFSafariViewController documentation 中对此进行了描述。 :
Use the SFSafariViewController class if your app lets users view websites from anywhere on the Internet. Use the WKWebView class if your app customizes, interacts with, or controls the display of web content.
关于Swift:如何拦截应用内浏览器中发出的网络请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37378059/