2013-09-22 9 views
1

在我的应用我启动摄像头,让用户拍照:内存泄漏后,我把照片从UIImagePickerControllerSourceTypeCamera

UIImagePickerController *imagePickerControllerSubject = [[UIImagePickerController alloc] init]; 

    imagePickerControllerSubject.delegate = self; 

    imagePickerControllerSubject.sourceType = UIImagePickerControllerSourceTypeCamera; 

    [self presentModalViewController:imagePickerControllerSubject animated:YES]; 

而拍摄完成后,我得到了内存泄漏,你可以看到我Xcode Instrument的屏幕截图。

enter image description here

予分离的代码。我确定它来自相机,而不是我的应用程序,我没有在我的didFinishPickingImage函数中留下任何东西。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo 
    { 

      [picker dismissModalViewControllerAnimated:YES]; 

      return; 

    } 

我使用ARC,所以我并不需要释放imagePickerControllerSubject

这是在Xcode仪器

我使用最新版本的ios7

任何想法的截图?

感谢

编辑

我过去在这里我的视图控制器的整个代码。它不能更简单。不要忘记,我只能在iOS 7中使用这种内存泄漏,并且只能在摄像机类型中使用。

#import "FeedbackVC.h" 

    @interface FeedbackVC() 

    @end 

    @implementation FeedbackVC 

    - (IBAction)onClickTakePicture 
    { 

     NSLog(@"onClickTakePicture"); 

     imagePickerControllerSubject = [[UIImagePickerController alloc] init]; 

     imagePickerControllerSubject.delegate = self; 

     imagePickerControllerSubject.sourceType =    UIImagePickerControllerSourceTypeCamera; 

     [self presentModalViewController:imagePickerControllerSubject animated:YES]; 

    } 

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo 
    { 


     picker.delegate = nil; 
     [self dismissViewControllerAnimated:NO completion:nil]; 
     picker = nil; 

     NSLog(@"imagePickerController"); 

    } 

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
    { 
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 

     if (self) 
     { 
      // Custom initialization 
      if (self) 
      { 
       self.navigationItem.title = @"Feedback"; 

       self.title = @"Feedback"; 

       self.tabBarItem.image = [UIImage imageNamed:@"second"]; 
      } 

     } 


     return self; 
    } 

    - (void)viewDidLoad 
    { 
     [super viewDidLoad]; 

    } 

    - (void)didReceiveMemoryWarning 
    { 
      [super didReceiveMemoryWarning]; 
      // Dispose of any resources that can be recreated. 
    } 

    @end 

回答

1

在:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo 

尝试:

picker.delegate = nil 
[self dismissViewControllerAnimated:NO completion:nil]; 
picker = nil; 
+0

没有工作:(我仍然有内存泄漏,该方法被调用后立即(且仅当照片已。拍摄相机拍摄) –

+0

@JeanFrançoisManatane您是否有相机视图覆盖?如果是这样,这将是有益的,如果你张贴一些代码 – Unheilig

+0

没有覆盖:(我不真的使用相机,只是imagepicker瓦特ith相机源类型。 –