gpt4 book ai didi

ios - 显示一个 ViewController,关闭它,然后进入另一个 View

转载 作者:搜寻专家 更新时间:2023-11-01 06:18:17 26 4
gpt4 key购买 nike

我正在尝试执行以下操作:

  1. 用户按下按钮
  2. UIImagePickerController弹出
  3. 用户选择图片
  4. UIImagePickerController 被关闭
  5. 进入另一个 ViewController

截至目前,我已将其设置为当用户按下按钮时,UIImagePickerController 会被初始化并与 presentViewController 一起显示。它也被委托(delegate)给这个按钮链接到的类。用户选择图片后,调用 imagePickerController,同时调用 dismissViewControllerAnimated。然后,调用 performSegueWithIdentifier。然而,这最后一步抛出以下警告,然后不继续:

2016-09-15 03:45:44.870 Food Diary[9941:1540144] Warning: Attempt to present on whose view is not in the window hierarchy!

我是 Swift 和 iOS 开发的新手,这是什么意思,我该如何解决?

最佳答案

UIImagePickerController 关闭完成时执行 segue

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
// your code
self.dismissViewControllerAnimated(true, completion: {
self.performSegueWithIdentifier("SegueIdentifier", sender: self)
})
}

注意:对于发送者,我已经传递了当前的 Controller 对象,您可以传递任何您想要的对象。

关于ios - 显示一个 ViewController,关闭它,然后进入另一个 View,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39505931/

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