Man*_*uel 6 uinavigationbar uiimagepickercontroller uinavigationcontroller ios swift
在UIImagePickerController
使用相机拍摄图像时的委托中,另一个视图被推送到导航堆栈上:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
picker.pushViewController(otherViewController, animated: true)
}
Run Code Online (Sandbox Code Playgroud)
在otherViewController
导航栏中可见:
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.setNavigationBarHidden(false, animated: false)
}
Run Code Online (Sandbox Code Playgroud)
当< Back
点击导航栏中的按钮时,导航栏再次变得不可见,出现相机视图,但相机图像被冻结并且点击底部栏按钮无效。
这是为什么?
A workaround is not to offer the user to navigate back by replacing the Back
button with a Cancel
button. That dismisses the UIImagePickerController and automatically dismisses all higher views on the navigation stack, including the otherViewController
.
// Replace `Back` button with `Cancel` button in the `otherViewController`
navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(self.cancelButtonTapped))
@objc func cancelButtonTapped() {
// Dismiss the `UINavigationController`, e.g. by calling a delegate function
// ...
}
Run Code Online (Sandbox Code Playgroud)
As a result the user would have to start the process again from the beginning instead of just navigating back.
归档时间: |
|
查看次数: |
494 次 |
最近记录: |