我有一个自UITabBarController
定义按钮。当我单击此按钮时,我会打开SFSafariViewController
- 这里一切正常。但是当我点击“完成”按钮时,SFSafariViewController
它会被关闭。但我无法返回UITabBarController
,我只看到我在应用程序委托窗口中添加的背景颜色。
示例代码:
class TabBar: UITabBarController, UITabBarControllerDelegate, SFSafariViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
delegate = self
}
func setupCenterButton() {
let centerButton = CenterButton(frame: CGRect(x: 0, y: 0, width: 74, height: 74))
centerButton.layer.cornerRadius = 37
centerButton.frame.origin.y = self.tabBar.frame.minY - 37
centerButton.frame.origin.x = view.bounds.width/2 - 37
centerButton.setImage(UIImage(named: "google"), for: .normal)
centerButton.addTarget(self, action: #selector(openURL), for: .touchUpInside)
view.addSubview(centerButton)
view.layoutIfNeeded()
}
@objc func openURL() {
let termsURL = SFSafariViewController(url: URL(string: "https://google.ru")!)
termsURL.modalPresentationStyle = .currentContext
termsURL.delegate = self
self.present(termsURL, animated: true, completion: nil)
}
}
UITabBarController
之后我该如何呈现SFSafariViewController
?