我的应用程序可以打开PDF文件。所以我将它注册为PDF文件。当我从邮件应用程序打开PDF文件时,我的应用程序会被调用,并且会调用以下功能:回到上一个应用程序(Swift ios)
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
}
This Works!如果用户点击ok按钮,我想回到邮件应用程序。我怎样才能做到这一点?我读过,那个苹果不允许你在应用程序之间切换。但是WhatsApp正在这样做。
我取出的viewController试了一下:
viewController.view.removeFromSuperview()
但后来我只得到一个黑色的屏幕。
这不会帮助你回到邮件应用程序viewController.view.removeFromSuperview() – Hasya
这不像你的答案帮助我:)。你有解决这个问题的办法吗? – ReasyEasyPeasy