gpt4 book ai didi

ios - didFinishPickingMediaWithInfo 未调用

转载 作者:IT王子 更新时间:2023-10-29 05:12:46 25 4
gpt4 key购买 nike

我有一个 UITableViewCell 按钮可以拍摄图像并将其放回单元格中。当我调用 UIImagePickerController 并拍摄图像时,它不会调用以下委托(delegate):

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject], sender:AnyObject)

这是我在 UITableViewController 中的 takePhotoFunction:

@IBAction func takePhoto(sender: AnyObject) {
let imagePickerController = UIImagePickerController()
imagePickerController.delegate = self
imagePickerController.allowsEditing = true

let actionSheet = UIAlertController(title: "Choose image souruce", message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)

actionSheet.addAction(UIAlertAction(title: "Take Image", style: UIAlertActionStyle.Default, handler: { (alert:UIAlertAction!) -> Void in
imagePickerController.sourceType = UIImagePickerControllerSourceType.Camera
self.presentViewController(imagePickerController, animated: true, completion: nil)
}))

actionSheet.addAction(UIAlertAction(title: "Photo Library", style: UIAlertActionStyle.Default, handler: { (alert:UIAlertAction!) -> Void in
imagePickerController.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
self.presentViewController(imagePickerController, animated: true, completion: nil)
}))
actionSheet.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil))
self.presentViewController(actionSheet, animated: true, completion: nil)}

最佳答案

Swift 3 中,这个委托(delegate)方法现在被称为:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])

区别是:

  1. 选择器前有一个下划线_
  2. 末尾的信息类型从 [String : AnyObject] 更改为 [String : Any]

我遇到了同样的问题,当我进行这些更改时它起作用了。

关于ios - didFinishPickingMediaWithInfo 未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29189548/

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