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]; 
  • UIImagePicker允许Editing卡在中心
  • 在iOS中检测相机的权限
  • iPhone“,超过最多5个过滤专辑列表试图注册。 这将失败。“错误
  • iOS 8 SDK:模态UIWebView和相机/图像select器
  • 上传后iOS iOS UIImagePickerController结果图像方向
  • 我可以从URL加载UIImage?
  • 裁剪UIImage
  • UIImagePickerController不在iOS 8中呈现
  • UIImagePickerController不填充屏幕
  • iOS 8快照未呈现的视图会导致一个空的快照
  • didFinishPickingMediaWithInfo返回零照片