Ram Ram - 4 months ago 54
Objective-C Question

presentModalViewController:Animated is deprecated in ios6

I am using the following code for an image picker. But when I run it in the simulator, I have a memory leak and I get a warning about

presentModalViewcontroller:animated
being deprecated in iOS6. I also get
dismissModalViewController:animated
deprecated. I'm using the SDK 6.1.

Code for ImagePicker:

- (void)showAlbum:(id)sender {
imagePicker=[[UIImagePickerController alloc]init];
imagePicker.delegate = self;
imagePicker.allowsEditing =NO;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:imagePicker animated:YES];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
//release picker
[picker dismissModalViewControllerAnimated:YES];
}

Answer

Use this line & check:

[self presentViewController:imagePicker animated:YES completion:nil];