我已经学习了tutorial iOS 应用程序开发。在“使用 View Controller ”部分,它教我如何实现函数来处理用户选取图像的事件:
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
// The info dictionary contains multiple representation of the image, and this uses original
let selectedImage = info[UIImagePickerControllerOriginalImage] as! UIImage
// Set PhotoImageView to display the selected image
photoImageView.image = selectedImage
// Dismiss the picker
dismissViewControllerAnimated(true, completion: nil)
}
我无法理解“let selectedImage = ...”行的含义,特别是 UIImagePickerControllerOriginalImage 部分。教程的解释是:
The info dictionary contains the original image that was selected in the picker, and the edited version of that image, if one exists. To keep things simple, you’ll use the original, unedited image for the meal photo.
那么,什么是“原创”和“编辑”?有什么区别?
最佳答案
UIImagePickerController
有一个 allowsEditing
属性,当设置为 true 时,允许用户编辑静态图像或电影。
因此,UIImagePickerControllerOriginalImage
和 UIImagePickerControllerEditedImage
是有意义的,因为它们代表 2 个不同的图像,一个是原始图像,另一个是用户编辑过的图像。
关于iOS 开发 : What does "original" mean in UIImagePickerControllerOriginalImage?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37549820/