presentModalViewController:Animated已在ios6中弃用
我正在使用下面的代码图像select器。 但是当我在模拟器中运行它,我有一个内存泄漏,我得到一个关于presentModalViewcontroller:animated
的警告presentModalViewcontroller:animated
在iOS6中被弃用。 我也得到dismissModalViewController:animated
不推荐使用。 我正在使用SDK 6.1。
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]; }
使用这一行和检查:
[self presentViewController:imagePicker animated:YES completion:nil];
[[Picker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
代替
[[Picker parentViewControl] dismissModalViewControllerAnimated:YES];
和
[self presentViewController:picker animated:YES completion:nil];
代替
[self presentModalViewController:picker animated:YES];
维沙尔提到
[self presentViewController:imagePicker animated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
确保你添加了“completion:nil”
if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]) { [self presentViewController:objSignupViewController animated:^{} completion:nil]; } else { [self presentModalViewController:objSignupViewController animated:YES]; }
使用:
[self presentViewController:imagePicker animated:YES completion:nil];
然后为你的解雇模式使用:
[self dismissViewControllerAnimated:controller completion:nil];
要么
[self dismissViewControllerAnimated:YES completion:nil];