iOS5上的UIImagePickerController内存泄漏 [英] UIImagePickerController memory leak on iOS5

查看:121
本文介绍了iOS5上的UIImagePickerController内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用UIImagePickerController在iOS5& XCode4.2,内存泄漏,我不知道为什么我会得到这个泄漏,请你给我答案。

i am using UIImagePickerController in my application developing on iOS5 & XCode4.2, getting memory leak and i don't have any idea why i am getting this leak can you please give me the answer for this.

和我的代码:

-(void)createImagePicker 
{
_picker = [[UIImagePickerController alloc] init];
_picker.sourceType = UIImagePickerControllerSourceTypeCamera;

_picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;

_picker.allowsEditing = YES;
_picker.showsCameraControls = NO;


_picker.cameraDevice = UIImagePickerControllerCameraDeviceRear; 

_picker.delegate = self;
_picker.wantsFullScreenLayout = YES;

}

和viewWillApper方法:

and viewWillApper method:

    -(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(closeCameraButton:) name:@"ShowMainView" object:nil];
    [self createImagePicker];
    [m_cameraOverlayView setBackgroundColor:[UIColor clearColor]];
    [self presentModalViewController:_picker animated:NO];
    _picker.cameraOverlayView = m_cameraOverlayView;

    [cameraImgView setHidden:YES];
    [filterView setHidden:YES];
    m_cameraOverlayView.hidden = NO;
    cameraSelectedButton.hidden = NO;
    cancelButton.hidden = YES;
    selectButton.hidden = YES;

    for (id Object in [scrollview subviews])
    {
        if([Object isKindOfClass:[UIButton class]])
        {
            [Object removeFromSuperview];
        }
    }

    [m_toolbarImage setFrame:CGRectMake(0, 427, 320, 55)];
    [cameraSelectedButton setFrame:CGRectMake(128, 432, 86, 44)];

    [m_cancelButton setFrame:CGRectMake(10, 434, 82, 40)];
    [m_cancelButton setTitle:@"Close" forState:UIControlStateNormal];
    [m_cancelButton setBackgroundImage:[UIImage imageNamed:@"menu-bar-button.png"] forState:UIControlStateNormal];
    [m_cancelButton setTitleColor:[UIColor colorWithRed:110/256.0 green:52/256.0 blue:28/256.0 alpha:1.0] forState:UIControlStateNormal];


    [cancelButton setFrame:CGRectMake(120, 434, 35, 35)];
    [selectButton setFrame:CGRectMake(184, 434, 35, 35)];

    }


推荐答案

这似乎无论是否使用ARC,iOS 5中的UIImagePickerController都会出现问题。

This seems to be a problem with UIImagePickerController in iOS 5 whether using ARC or not.

我有一个使用xcode 3.2.5为iOS 4开发的应用程序,当从图书馆拍摄或选择照片时,仪器显示没有泄漏(在运行的设备上测试) iOS 4.1)。在运行iOS 5.1的设备上测试的相同代码如上所述泄漏。

I have an app developed for iOS 4 using xcode 3.2.5 and Instruments shows no leaks when a photo is either taken or selected from the library (tested on a device running iOS 4.1). The same code tested on a device running iOS 5.1 leaks as described.

我知道这不是一个答案,但问题似乎比原始问题更广泛。

I know this isn't an answer but the problem seems broader than the original question.

这篇关于iOS5上的UIImagePickerController内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆