我已经使用仪器测试了我的应用程序,它显示了以下泄漏。
当我双击堆栈跟踪中的 CameraVC 时,它会在我的代码中引用以下行。
当我调用相机时会发生这种情况,我使用以下代码调用它:-
- (IBAction) getCamera
{
// set up our camera overlay view
// tool bar - handy if you want to be able to exit from the image picker...
UIToolbar *toolBar=[[UIToolbar alloc] initWithFrame:CGRectMake(0, 480-44, 320, 44)];
UIBarButtonItem *spaceItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil] autorelease];
UIBarButtonItem *spaceItem1 = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil] autorelease];
UIBarButtonItem *cancelItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelPickingImag)] autorelease];
UIBarButtonItem *cameraItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(finishedAugmentedReality)] autorelease];
spaceItem.width = 2.0;
spaceItem1.width = 55.0;
NSArray *items=[NSArray arrayWithObjects:spaceItem,cancelItem,spaceItem1,cameraItem,nil];
[toolBar setItems:items];
// create the overlay view
overlayView=[[OverlayView alloc] initWithFrame:CGRectMake(0, 300, 320, 480-44)];
// important - it needs to be transparent so the camera preview shows through!
overlayView.opaque=NO;
overlayView.backgroundColor=[UIColor clearColor];
// parent view for our overlay
UIView *parentView=[[UIView alloc] initWithFrame:CGRectMake(0,0,320, 480)];
[parentView addSubview:overlayView];
[parentView addSubview:toolBar];
[parentView addSubview:lbl];
[parentView addSubview:overlayGraphicView];
// configure the image picker with our overlay view
//UIImagePickerController *picker=[[UIImagePickerController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera])
{
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
// hide the camera controls
imagePicker.showsCameraControls=NO;
imagePicker.delegate = self;
//imagePicker.allowsImageEditing = NO;
// and put our overlay view in
imagePicker.cameraOverlayView=parentView;
}
else
{
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = NO;
}
[self presentModalViewController:imagePicker animated:YES];
//Free memory
[imagePicker release];//,imagePicker =nil;
[parentView release], parentView=nil;
[overlayGraphicView release], overlayGraphicView= nil;
[lbl release], lbl=nil;
[overlayView release];//, overlayView =nil;
[toolBar release], toolBar=nil;
}
非常感谢任何帮助
谢谢