我使用下面的代码的图像拾取。 但是,当我在模拟器中运行它,我有内存泄漏,我得到一个关于警告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];
请确保您已经添加“完成:无”以及
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];