Leak detected on UIImagePickerController view

Here is the code I use for presentation UIImagePickerController:

- (IBAction)takePhoto:(UIButton *)sender {

  if (![UIImagePickerController
          isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

    UIAlertController *alert = [UIAlertController
        alertControllerWithTitle:NSLocalizedString(@"Error", nil)
                         message:NSLocalizedString(@"Device has no camera", nil)
                  preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *ok =
        [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
                                 style:UIAlertActionStyleDefault
                               handler:nil];
    [alert addAction:ok];
    [self presentViewController:alert animated:YES completion:nil];

  } else {

    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    picker.videoQuality = UIImagePickerControllerQualityTypeMedium;

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

I am currently running this method (e.g. click on UIButton). I see this in Tools:

Leaks on the way back

And this is what I see if I switch to Cycles and Roots:

Loops and roots

So, if I move on to the first leak and click on the arrow that appears, I get the following:

enter image description here

and if I open the stack trace for this method, I see:

enter image description here

So these are basically system calls. The same goes for other leaks, just system calls ... So is this a mistake or ?? If I open and remove the image picker several times, I get even more leaks, much more ...

Has anyone noticed this?

+4
1

UIImagePickerController * picker . , .

+1

Source: https://habr.com/ru/post/1668387/


All Articles