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]; } 

5 Solutions collect form web for “presentModalViewController:Animated已在ios6中弃用”

使用这一行和检查:

 [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]; 
  • UIImagePickerController摄像头视图在iOS 8上奇怪的旋转(图片)
  • UIImagePickerController错误:快照未呈现的视图会导致iOS 7中的空快照
  • 什么时候应该使用UIImagePickerControllerSourceTypePhotoLibrary而不是UIImagePickerControllerSourceTypeSavedPhotosAlbum?
  • UIImagePicker允许Editing卡在中心
  • UIImagePickerController不在iOS 8中呈现
  • 在iOS中检测相机的权限
  • 调整从相机拉取的UIimages的大小也旋转的UIimage?
  • 我可以从URL加载UIImage?