ほぼ完成したアプリがありますが、QA を行っているときに、QA エンジニアは、UIImagePickerController
ビューで [USE] をタップすると黒い画面が表示されるというランダムな問題に遭遇しました。さらにdidFinishPickingMediaWithInfo
、画像は将来の参照用に保存されており、 に表示されてUIImageView
います。ボタンを に追加するためにカメラ オーバーレイも使用しており、アプリの最大メモリ使用量は13 MBUIImagePickerView
を超えていません。キャプチャ モードからカメラ ロール モードに切り替えた場合、問題は発生しません。また、同じビューで提示されています。その下には、問題が関係している可能性のあるコードがあり、問題のアイデアを得るために画像も添付されています。どんな助けでも大歓迎です。iADs
前もって感謝します。
(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];
}
}