A black screen appears randomly after taking an image and pressing "USE" in the UIImagePickerController

I have an application that is almost done, and now that it was under QA, the QA engineer ran into a random problem in which a black screen appears after clicking on USE in the UIImagePickerController . In addition, in didFinishPickingMediaWithInfo image is saved for future repetition and displayed in UIImageView , I also use the camera overlay to add a button to UIImagePickerView , and the maximum memory usage of the application does not go above 13 MB . The problem does not occur when switching to camera roll mode from shooting mode. Also in the same view are iADs . Under the codec to which the problem relates, images are also attached to get an idea of ​​the problem. Any help would be greatly appreciated.

Thanks in advance.

Image Picker Controller

THIS IMAGE IS CORRECT, THIS IS HOW THE VIEW SHOULD BE PRESENTED

RANDOMLY THIS SCREEN APPEARS AFTER TAPPING ON USE, THOUGH ON NAVIAGTING TO AND FRO TO OTHER TABS THE CORRECT SCREEN [THE SCREEN NUMBER 2] DOES APPEARS.

 (void) launchCamera { // Set up the camera\ CustomCameraView *cameraController = [[CustomCameraView alloc] init]; cameraController.sourceType = UIImagePickerControllerSourceTypeCamera; cameraController.delegate = self; cameraController.showsCameraControls = YES; cameraController.navigationBarHidden = YES; cameraController.toolbarHidden = YES; // overlay on top of camera lens view UIButton *cameraRoll = [[UIButton alloc] initWithFrame:CGRectMake(15, 380, 40, 40)]; [cameraRoll setAlpha:0.0f]; [cameraRoll setBackgroundImage:[UIImage imageNamed:@"CamerRoll_New"] forState:UIControlStateNormal]; [cameraRoll addTarget:self action:@selector(switchToCameraRoll) forControlEvents:UIControlEventTouchUpInside]; cameraController.cameraOverlayView = cameraRoll; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDelay:1.5f]; cameraRoll.alpha = 1.0f; [UIView commitAnimations]; [self presentModalViewController:cameraController animated:YES]; } -(void)switchToCameraRoll { DLog(@"Camera Roll"); [self dismissViewControllerAnimated:NO completion:^(void){ [self photoSourcePhotoAlbum];}]; } -(void) photoSourcePhotoAlbum { UIImagePickerController * picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; [self presentModalViewController:picker animated:YES]; } - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self.view addSubview:progressView]; timer = [NSTimer scheduledTimerWithTimeInterval:.017 target:self selector:@selector(progressChange) userInfo:nil repeats:YES]; [picker dismissModalViewControllerAnimated:YES]; [self performSelectorInBackground:@selector(saveImage:) withObject:info]; [self performSelector:@selector(navigateToEditView) withObject:nil afterDelay:2.1]; } -(void)navigateToEditView { [self performSegueWithIdentifier:@"presentRDetailModalViewController" sender:self]; } - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { if (picker.sourceType == UIImagePickerControllerSourceTypeSavedPhotosAlbum) { [picker dismissViewControllerAnimated:NO completion:^(void){ [self photoSourceCamera];}]; } else { [picker dismissModalViewControllerAnimated:YES]; } } -(void)saveImage:(NSDictionary *)info { NSString *imageName = [[[DataStaging dataStaging] getGUID] stringByAppendingString:@".jpg"]; rImageName = imageName; UIImage *rImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; //Compress image [[FileOperations fileOperations] PersistData:UIImageJPEGRepresentation(rImage, 0.4) name:imageName]; DLog(@"%@",[[FileOperations fileOperations] fetchPath:imageName]); //Actual image taken [[self rImageView] setImage:[info objectForKey:@"UIImagePickerControllerOriginalImage"]]; if ([rImageName length] == 0) { [[self rDetails] setHidden:YES]; [[self trashRImage] setHidden:YES]; } else { [[self rDetails] setHidden:NO]; [[self trashRImage] setHidden:NO]; } [progressView removeFromSuperview]; } } 
+4
source share
1 answer

Make sure you don't call presentModalViewController: animated: twice before rejectingMMalalViewControllerAnimated: This helped me in my case.

 - (void)showImagePickerForSourceType:(UIImagePickerControllerSourceType)sourceType { if (_imagePickerController!=nil || _imagePopoverController!=nil) { return; } _imagePickerController = [[[UIImagePickerController alloc] init] autorelease]; _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; _imagePickerController.sourceType = sourceType; _imagePickerController.delegate = self; switch (sourceType) { case UIImagePickerControllerSourceTypeCamera: _imagePickerController.showsCameraControls = YES; [self presentViewController:_imagePickerController animated:YES completion:nil]; break; default: _imagePopoverController = [[UIPopoverController alloc] initWithContentViewController:_imagePickerController]; _imagePopoverController.delegate = self; CGRect rect = [[UIScreen mainScreen] bounds]; rect.origin.y = rect.size.height - 70.0; rect.size.height -= rect.origin.y; [_imagePopoverController presentPopoverFromRect:rect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES]; break; } } - (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker { [_imagePopoverController dismissPopoverAnimated:YES]; _imagePopoverController = nil; [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; _imagePickerController = nil; } - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info { UIImageWriteToSavedPhotosAlbum([info objectForKey:UIImagePickerControllerOriginalImage],nil,nil,nil); _currentImage = [info objectForKey:UIImagePickerControllerOriginalImage]; [_imagePopoverController dismissPopoverAnimated:YES]; _imagePopoverController = nil; [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; _imagePickerController = nil; } 
0
source

All Articles