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]; 
  • 调整从相机拉取的UIimages的大小也旋转的UIimage?
  • Swift PNG图像以不正确的方向保存
  • iOS 8快照未呈现的视图会导致一个空的快照
  • Xcode 8 - 创build一个未知types的图像格式是一个错误
  • 使用UIImagePickerController时,iOS 10错误 <私人>
  • 什么时候应该使用UIImagePickerControllerSourceTypePhotoLibrary而不是UIImagePickerControllerSourceTypeSavedPhotosAlbum?
  • 将选取的图像保存到CoreData
  • 在横向上使用UIImagePickerController
  • UIImagePickerController错误:快照未呈现的视图会导致iOS 7中的空快照
  • iOS 8 SDK:模态UIWebView和相机/图像select器
  • 上传后iOS iOS UIImagePickerController结果图像方向