我正在将4 UIImageView
与UIImagePickerController
一起使用。我想使用相机拍摄在imageview 1中显示的照片,然后再次拍摄我想在imageview 2中显示的照片,但是问题是如果我再次拍摄也仅在Imageview1中显示的照片。
这里是我的代码
@IBOutlet weak var CameraOutlet: UIButton!
@IBOutlet weak var Complaint_Image1: UIImageView!
@IBOutlet weak var Complaint_Image2: UIImageView!
@IBOutlet weak var Complaint_Image3: UIImageView!
@IBOutlet weak var Complaint_Image4: UIImageView!
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
dismiss(animated: true, completion: nil)
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let picture = info[UIImagePickerControllerOriginalImage] as! UIImage
Complaint_Image1.image = picture
if Complaint_Image1 != nil {
Complaint_Image2.image = picture
}
dismiss(animated: true, completion: nil)
}
答案 0 :(得分:0)
您的逻辑应该是:
这些行:
Complaint_Image1.image = picture
if Complaint_Image1 != nil {
Complaint_Image2.image = picture
}
应该是
if Complaint_Image1.image != nil {
Complaint_Image2.image = picture
} else {
Complaint_Image1.image = picture
}