【问题标题】:How to close SFSafariViewController automatically when reaching a certain page到达某个页面时如何自动关闭SFSafariViewController
【发布时间】:2016-12-27 17:03:07
【问题描述】:

我想在用户上传内容后到达 Dropbox 网站的“谢谢”页面时自动关闭 SFSafariViewController;它需要自动关闭。我怎样才能做到这一点?

这是我目前所拥有的:

@IBAction func Singles5(_ sender: Any) {
    let safariVC = SFSafariViewController(url: NSURL(string: "https://www.dropbox/Upload")! as URL)
    self.present(safariVC, animated: true, completion: nil)
    safariVC.delegate = self
}

【问题讨论】:

  • 投票赞成的问题。现在,您有任何个可能的例子吗? (自 Swift 2 以来,我没有在任何个人或专业领域使用过 SFSafariViewController。可以这样做吗?)
  • 我做了回答,检查我的回答Here

标签: ios sfsafariviewcontroller


【解决方案1】:

我能想到的一种方法是使用自定义 URL 方案。您可以在 Dropbox 的 callback 参数中指定应用的自定义 URL(如果 Dropbox 有回调)。因此,当用户上传完他/她的文件后,dropbox 会执行回调。在这种情况下,您的应用将收到回调,其中包含您指定的任何参数。这将在您的AppDelegate 中调用函数application(app, open, options)->Bool。现在,您可以使用对呈现SFSafariViewControllerViewController 的引用并调用SafariViewController.dissmissViewController()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-06
    • 2019-05-20
    • 1970-01-01
    • 2013-10-02
    • 2021-08-09
    • 1970-01-01
    相关资源
    最近更新 更多