首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何自动关闭SFSafariViewController?

如何自动关闭SFSafariViewController?
EN

Stack Overflow用户
提问于 2016-08-23 17:06:56
回答 1查看 4.1K关注 0票数 4

我想关闭SFSafariViewController而不需要用户点击左上角的完成按钮。

代码语言:javascript
复制
let svc = SFSafariViewController(URL: NSURL(string: "http://spotify.com")!)

self.presentViewController(svc, animated: true, completion: nil)
EN

回答 1

Stack Overflow用户

发布于 2018-05-29 17:48:34

我在这里添加这个解决方案,因为我正在寻找相同的行为,但我没有找到任何好的答案。

像这样展示你的SFSafariViewController:

代码语言:javascript
复制
    let URL = NSURL(string: "www.to-load.com")
    let webVC = SFSafariViewController(url: URL! as URL)
    present(webVC, animated: true)
    webVC.loadViewIfNeeded()

然后你可以像这样把它合上。

代码语言:javascript
复制
   self.navigationController?.popViewController(animated: true)
   self.dismiss(animated: true, completion: nil)

是的,我检查过了,它起作用了。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39096902

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档