我想上傳第三張,也許更多的圖像到圖像視圖上,但我不知道如何分離第三張圖像。前兩個工作正常,我如何添加第三個功能,我主要需要在func圖像選擇器控制器上的幫助,我認爲。如何分離這些圖像選擇器功能?
var selected = 1
@IBAction func pickImage1(_ sender: Any) {
let image = UIImagePickerController()
image.delegate = self
image.sourceType = UIImagePickerControllerSourceType.photoLibrary
image.allowsEditing = false
selected = 1
self.present(image, animated: true)
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
if selected == 1 {
myImageView1.image = image
} else {
myImageView2.image = image
return
}
//i tried putting myImageView3 here but it just replaced the 2nd
}
else {
//error
}
self.dismiss(animated: true, completion: nil)
}
@IBAction func pickImage2(_ sender: Any) {
let image2 = UIImagePickerController()
image2.delegate = self
image2.sourceType = UIImagePickerControllerSourceType.photoLibrary
image2.allowsEditing = false
selected = 2
self.present(image2, animated: true)
}
@IBAction func pickImage3(_ sender: Any) {
let image3 = UIImagePickerController()
image3.delegate = self
image3.sourceType = UIImagePickerControllerSourceType.photoLibrary
image3.allowsEditing = false
selected = 3
self.present(image3, animated: true)
}
獲取錯誤。 selected = tappedImage.tag – Riccardo
@Riccardo你得到了什麼錯誤? –
使用未解析的標識符「selected」 – Riccardo