【发布时间】:2016-11-24 13:22:29
【问题描述】:
我的应用程序可以打开 PDF 文件。所以我将它注册为 PDF 文件。当我从邮件应用程序打开 PDF 文件时,我的应用程序会被调用并调用以下函数:
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
let rect = app.keyWindow?.rootViewController?.view.bounds
viewController.view.backgroundColor = UIColor.red
let picker = UIPickerView(frame: CGRect(x: 0, y: 100, width: (rect?.width)!, height: (rect?.height)! / 3))
picker.delegate = self
picker.dataSource = self
viewController.view.addSubview(picker)
let okButton = UIButton(frame: CGRect(x: 0, y: 100 + ((rect?.height)! / 3), width: ((rect?.width)! / 2) - 20, height: 30))
okButton.setTitle("Ok", for: .normal)
okButton.addTarget(self, action: #selector(AppDelegate.endApp), for: .touchUpInside)
viewController.view.addSubview(okButton)
app.keyWindow?.rootViewController?.present(viewController, animated: true, completion: nil)
return true
}
这行得通!如果用户单击确定按钮,我想返回邮件应用程序。我怎样才能做到这一点?我读到,那个苹果不允许你在应用程序之间切换。但是 WhatsApp 正在这样做。
我尝试删除 viewController:
viewController.view.removeFromSuperview()
然后我只得到一个黑屏。
【问题讨论】:
-
这不会帮助您返回邮件应用程序 viewController.view.removeFromSuperview()
-
这对我的帮助不如你的回答:)。你有解决这个问题的办法吗?