公司开发的app中有慈善捐款的业务,然而根据苹果的审核机制,关于慈善捐款的操作只能在浏览器中进行,所以需就用到了SFSafariViewController
注意
- SFSafariViewController 和系统浏览器safari在外观上基本相同,并且
共享cookie
- SFSafariViewController 不支持手动输入地址.也无法通过代码修改URL
- URL只有在初始化中指定一次,只有的跳转只能通过用户点击页面中的跳转元素跳转
- SFSafariViewController现在只支持http和https格式的URL,所以现在想从SFSafariViewController跳入APP是不可能的了
- 妄图隐藏SFSafariViewController的显示审核会遭到拒绝
- 在viewDidAppear方法调用之前跳转到SFSafariViewController会造成白屏
使用方法
import SafariServices // 导入库
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let safariVC = SFSafariViewController(url: URL(string: "http://www.baidu.com")!)
self.navigationController?.pushViewController(safariVC, animated: true)
}
使用非常简单,因为SFSafariViewController并没有开放太多的功能给开发者.在我看来它仅仅是为了在APP内部浏览网页,唯一的优点也就是和safari共享cookie了吧