解雇imagePickerController内存后没有被释放

时间:2015-08-14 06:52:42

标签: objective-c memory-management uiimagepickercontroller

当用户从库中选择图片或取消时,我正在调用[picker dismissViewControllerAnimated:YES completion:NULL];。 我也将委托设置为nil只是为了确定,但这也无济于事。

我错过了什么吗?

-(void)callImagePickerDelegate:(CameraView *)sender{


UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

[self presentViewController:picker animated:YES completion:NULL];


self.imageFromLibrary.frame = CGRectMake(0, self.imageFromLibrary.frame.origin.y, self.imageFromLibrary.frame.size.width, self.imageFromLibrary.frame.size.width);}


- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

[picker dismissViewControllerAnimated:YES completion:NULL];

[self.cameraView.session startRunning];

picker.delegate = nil;}

2 个答案:

答案 0 :(得分:0)

我认为你已经宣称你的选择器是强大的属性,这就是为什么它没有释放它的记忆。

将您的选择器声明为弱属性,然后尝试。

希望它有所帮助。

答案 1 :(得分:0)

你只需要选择器的代表而不是实际的选择器对象。所以设置picker = nil,如果你没有使用ARC,那么也写picker = nil;[picker release];