gpt4 book ai didi

ios - 关闭 UIImagePickerController 也会关闭呈现的 View Controller

转载 作者:IT王子 更新时间:2023-10-29 05:38:57 24 4
gpt4 key购买 nike

我正在做一个使用标签栏系统的项目。 tabbar 的一项是 JobPostingViewController。我将它嵌入到 UINavigationController 中。在这个 View Controller 中有一个名为添加新作业的 UIButton。我实现了 pushviewcontroller 去 CreateJobPostViewController。我需要添加 UIImagePickerController 来选择图像。当我点击完成按钮或从库中选择图像时,它会关闭到 JobPostingViewController。但它应该转到 CreateJobPostViewController。任何人都请帮助我。提前致谢。

您可以在此处查看问题:
enter image description here

JobPostingViewController 中的代码

 @IBAction func openCreateJob(sender: AnyObject) {
let vc = self.storyboard?.instantiateViewControllerWithIdentifier("CreateJobPostViewController") as! CreateJobPostViewController
self.navigationController?.pushViewController(vc, animated: true)
}

CreateJobPostViewController 中的代码

   @IBAction func addImages(sender: AnyObject) {
imagePicker.allowsEditing = false
imagePicker.sourceType = .PhotoLibrary
presentViewController(imagePicker, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
picker.dismissViewControllerAnimated(true, completion: nil)
}
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
picker.dismissViewControllerAnimated(true, completion: nil)
}

最佳答案

通过将图像选择器的 modalPresentationStyle 设置为“OverCurrentContext”解决了这个问题:

picker.modalPresentationStyle = .overCurrentContext

关于ios - 关闭 UIImagePickerController 也会关闭呈现的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38167027/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com