After dismiss camera. It give me this warning: Attempt to present on while a presentation is in progress!
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:nil];
}
I don't know if this is a big issue.
More Code:
- (void) viewWillAppear:(BOOL)animated
{
[self takePicture];
}
- (void) takePicture
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
} else
[imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
imagePickerController.delegate = self;
[self presentViewController:imagePickerController animated:YES completion:nil];
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissViewControllerAnimated:NO completion:nil];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:NO completion:nil];
}
By the way, "dismissModalViewController" is deprecated.
Fix: ViewWillAppear will be invoked once there is a new view. That's the problem