Tung Fam Tung Fam - 1 year ago 67
Swift Question

Is it necessary to implement imagePickerControllerDidCancel?

While working on a simple app where you open a Photo Library then choose an image I faced with a function imagePickerControllerDidCancel.

As I understand this function will be performed upon the click on "Cancel" button (while Camera or Photo Lib is open). And inside this func you need to perform dismissViewControllerAnimated.

func imagePickerControllerDidCancel(picker: UIImagePickerController) {
dismissViewControllerAnimated(true, completion: nil)
}


But i tried not to implement it and the button Cancel was still working as it supposed to.

Is it necessary to use imagePickerControllerDidCancel or what is it for ?

Answer Source

Method imagePickerControllerDidCancel is optional delegate method of UIImagePickerControllerDelegate. If you want to perform some task on the cancel of UIImagePickerController then you can use this method.

Hope this will help you.