本文介绍了presentModalViewController:在ios6中不推荐使用Animated的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码作为图像选择器。但是当我在模拟器中运行它时,我有一个内存泄漏,我得到一个关于 presentModalViewcontroller:animated 在iOS6中被弃用的警告。我也得到 dismissModalViewController:动画已弃用。我正在使用SDK 6.1。

I am using the following code for an image picker. But when I run it in the simulator, I have a memory leak and I get a warning about presentModalViewcontroller:animated being deprecated in iOS6. I also get dismissModalViewController:animated deprecated. I'm using the SDK 6.1.

ImagePicker的代码:

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


推荐答案

使用此行& check:

Use this line & check:

[self presentViewController:imagePicker animated:YES completion:nil];

这篇关于presentModalViewController:在ios6中不推荐使用Animated的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 10:03