UIImagePickerController 오류 : 오류되지 않은 뷰를 스냅 샷하면 iOS 7에서 빈 스냅 샷이 생성됨
iOS 7에서만이 오류가 발생하고 응용 프로그램이 충돌했습니다. iOS 6에서는 카메라를 열 때 한 번만 메모리 경고가 발생하여 오류가 발생하지 않습니다.
Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.
여기 내가하고있는 일이 있습니다.
imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setDelegate:self];
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setAllowsEditing:YES];
[self presentModalViewController:imagePicker animated:YES];
presentModalViewController를 지연 시키려고 시도했지만 여전히 동일한 메시지가 나타납니다. 몇 초 (7-10) 후 응용 프로그램이 중단되었습니다.
이 오류는 iOS 7에서만 나타납니다.
아무도 단서가 있습니까? 미리 감사드립니다.
iOS7의 문제는 전환과 관련이 있습니다. 이전 전환이 갑자기 발생하면 새 전환을 시작하면 iOS7이보기를 엉망으로 만들고 iOS6이 표시되는 것처럼 보이게됩니다.
UIViewController뷰가로드되고 시간 초과가 해결해야 만 에서 카메라를 초기화합니다 .
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
//show camera...
if (!hasLoadedCamera)
[self performSelector:@selector(showcamera) withObject:nil afterDelay:0.3];
}
여기에 초기화 코드가 있습니다.
- (void)showcamera {
imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setDelegate:self];
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setAllowsEditing:YES];
[self presentModalViewController:imagePicker animated:YES];
}
이 오류는 Apple의 PhotoPicker 샘플 코드 프로젝트 오류입니다.
iPhone 4에서 Xcode 버전 5.0 및 iOS 7.0.3을 사용하고 있습니다.
재현 단계 :
https://developer.apple.com/library/ios/samplecode/PhotoPicker/Introduction/Intro.html 에서 Apple의 PhotoPicker 샘플 프로젝트를 다운로드 하십시오.
APLViewController.m에서 125 행을 주석 처리합니다.
//imagePickerController.showsCameraControls = NO;APLViewController.m에서 130-133 행을 주석 처리하십시오.
//[[NSBundle mainBundle] loadNibNamed:@"OverlayView" owner:self options:nil];
// self.overlayView.frame = imagePickerController.cameraOverlayView.frame;
// imagePickerController.cameraOverlayView = self.overlayView;
// self.overlayView = nil;앱을 빌드하고 실행합니다.
실행되면 기기를 가로 모드로 회전합니다.
카메라 아이콘을 클릭하여 카메라 모드에서 UIImagePickerController를 찾습니다 다.
콘솔 출력을 봅니다.
콘솔 출력
PhotoPicker [240 : 60b]되지 않은 뷰를 스냅 샷하면 빈 스냅 샷이 생성됩니다. 화면 업데이트 전에 스냅 샷 또는 스냅 샷 확인합니다.
showsCameraControls 속성
이 값이 YES (특허) 인 경우 문제가 발생합니다.
관리 NO로 설정하면 메시지가 제거됩니다.
버그 신고
방금 Apple에 버그 보고서를 출시했습니다.
다른 게시물에서 제안 된 많은 제안을 시도했지만 만족스러운 해결 방법을 제안했습니다.
팝 오버 안에 카메라 뷰를 표시 할 때 문제가 발생했습니다. iOS6에서는 문제가 없지만 iOS7에서는 메시지가 표시되었습니다.
Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.
매일.
그러나 사진 및 동영상 촬영에 설명 된대로 카메라보기의 프레젠테이션을 전체 화면으로 변경 한 후 iOS 개발자 라이브러리 모든 것이 다시 정상적으로 작동하고 메시지가 다시 나타나지 않았습니다. 그러나 앱이 어떤 모드에 있는지 (즉, 카메라 뷰 또는 사진 롤 표시)에 따라 메서드 - (void) imagePickerControllerDidCancel: (UIImagePickerController *) picker가 호출 될 때마다 팝 오버 또는 뷰 컨트롤러를 닫아야한다는 것을 확인해야했습니다 .
속성 생성
@property (nonatomic) UIImagePickerController *imagePickerController;
그때
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.modalPresentationStyle = UIModalPresentationCurrentContext;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.allowsEditing = YES;
self.imagePickerController = picker;
[self presentViewController:self.imagePickerController animated:YES completion:nil];
이것은 문제를 해결해야합니다
이 코드를 사용하여 문제를 해결했습니다.
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setDelegate:self];
if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]){
[imagePicker setShowsCameraControls:NO];
[self presentViewController:imagePicker animated:YES completion:^{
[imagePicker setShowsCameraControls:YES];
}];
} else {
[imagePicker setShowsCameraControls:YES];
[self presentModalViewController:imagePicker animated:YES];
}
나는 같은 문제가 있고 해결 방법을 찾았습니다. 응용 프로그램의 방향과 관련된 오류라고 생각합니다. 내 응용 프로그램은 가로 모드 만 사용하지만 UIImagePickerController는 세로 모드를 사용합니다. main.m에 try-catch 블록을 추가하고 실제 예외가 발생합니다.
Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES
이 문제를 해결하는 방법 :
1) Target-> General 또는 .plist 파일에서 장치 방향을 다시 확인하십시오. 지원되는 인터페이스 방향 : 가로 왼쪽, 가로 오른쪽.
2) AppDelegate.m에 추가하십시오.
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskLandscape | UIInterfaceOrientationMaskPortrait;
}
이 단계 후에 UIImagePickerController가 제대로 작동하지만 내 뷰 컨트롤러는 세로 모드로 회전 할 수 있습니다. 따라서 이것을 해결하려면 :
3) UINavigationController에 대한 범주를 만듭니다 (supportedInterfaceOrientations가 iOS6의 UIViewController에서 UINavigationController로 이동 됨).
@implementation UINavigationController (RotationIOS6)
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
@end
이 솔루션은 iOS 6.0, 6.1, 7.0에서 제대로 작동합니다. 도움이 되었기를 바랍니다.
iOS SDK 6.1, 배포 대상 iOS 6.1로 앱을 빌드하고 iOS 7 기반 iPhone에서 앱을 실행할 때이 오류가 발생합니다. 앱이 충돌하지 않지만 UIViewController shouldAutorotate방법을 구현 하면 오류 메시지를 제거하는 데 도움이됩니다.
- (BOOL)shouldAutorotate {
return YES;
}
Avirary SDK 와 함께 제공되는 데모 앱을 수정하려고 할 때 동일한 문제가 발생 했습니다. 데모 앱에서는 카메라 롤에서 선택한 사진 만 편집 할 수 있습니다. 카메라에서 캡처하여 사진을 편집하려면 먼저 UIViewcontroller.m 파일에 다음 코드를 추가했습니다.
#pragma mark - Take Picture from Camera
- (void)showCamera
{
//[self launchPhotoEditorWithImage:sampleImage highResolutionImage:nil];
if ([self hasValidAPIKey]) {
UIImagePickerController * imagePicker = [UIImagePickerController new];
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setDelegate:self];
[imagePicker setAllowsEditing:YES]; //important, must have
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self presentViewController:imagePicker animated:YES completion:nil];
}else{
[self presentViewControllerInPopover:imagePicker];
}
}
}
그런 다음 앱을 실행할 때 오류가 발생했습니다.
Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.
오류를 해결하려면 아래와 같이 UIViewContooler.m 파일에서 UIImagePicker 대리자를 수정했습니다.
#pragma mark - UIImagePicker Delegate
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSURL * assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
void(^completion)(void) = ^(void){
[[self assetLibrary] assetForURL:assetURL resultBlock:^(ALAsset *asset) {
if (asset){
[self launchEditorWithAsset:asset];
}
} failureBlock:^(NSError *error) {
[[[UIAlertView alloc] initWithTitle:@"Error" message:@"Please enable access to your device's photos." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}];
UIImage * editedImage = [info objectForKey:UIImagePickerControllerEditedImage];
if(editedImage){
[self launchPhotoEditorWithImage:editedImage highResolutionImage:editedImage];
}
};
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self dismissViewControllerAnimated:YES completion:completion];
}else{
[self dismissPopoverWithCompletion:completion];
}
}
그런 다음 오류가 사라지고 앱이 작동합니다!
이것을 시도하고 사용하십시오
[self performSelector:@selector(presentCameraView) withObject:nil afterDelay:1.0f];
및 기능
-(void)presentCameraView{
[self presentViewController:imagePicker animated:YES completion:nil];
}
교체. [self presentModalViewController:imagePicker animated:YES];원인 imagePicker은 전역 변수로 만듭니다.
이것이 내 앱 ymmv에서 나를 위해 수정 한 것입니다.
먼저 iPhone-iPad 앱입니다.
appname-Info.plist에 있습니다. 지원되는 인터페이스 방향 (iPad)에서 4 개의 방향이 표시되었습니다.
지원되는 인터페이스 방향에서 3 개의 방향이 표시되었습니다. 네 번째를 추가하고 디버그 출력없이 앱을 실행했습니다.
도움이 되었기를 바랍니다.
방금 같은 문제가 발생했습니다. 제 경우 문제는 ARC가 아닌 코드가 있고 ARC로 마이그레이션했다는 것입니다. 마이그레이션을 수행 할 때를 강력하게 언급하지 않았고 그것이 UIImagePickerController충돌의 원인이었습니다.
도움이되기를 바랍니다 :)
iOS 8에서도 같은 문제가 있었지만 카메라 액세스는 내 앱의 설정-> 개인 정보 에서 비활성화되었습니다 . 그냥 활성화하고 작동했습니다.
나는 해결책을 찾기 위해 오랜 시간을 보냈고 놀랍게도 결국 그것을 찾았고 그것을 발견 한 후에는 매우 재미있었습니다.
선택한 이미지를 검색하고 작업을 재개하기 위해 수행 할 작업은 다음과 같습니다.
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
UIImage* pickedImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[composeImageView setImage:pickedImage];
[picker dismissViewControllerAnimated:YES completion:nil];
}
예, 문제를 해결하려면 다음 메시지처럼 일반적으로 선택기를 닫으면됩니다. "렌더링되지 않은 뷰를 스냅 샷하면 빈 스냅 샷이 생성됩니다. 스냅 샷을 생성하기 전에 뷰가 한 번 이상 렌더링되었는지 확인하거나 화면 업데이트. " 선택기가 응답하는 것을 중지하지만 선택기를 닫고 이미지를 정상적으로 검색 할 수 있습니다.
제 경우에는 레이아웃 변경과 관련이 있습니다. VC를 표시하는 VC UIImagePickerViewController에는 상태 표시 줄이 숨겨져 있지만 UIImagePickerViewController그렇지 않습니다.
그래서이 답변에UIImagePickerViewController 표시된대로 상태 표시 줄을 숨기는 문제를 해결했습니다 .
질문에 직접 대답하지 않았지만 메모리 경고가 있다고 언급 했으므로 메모리 경고로 이어질 수있는 속성에 원시 이미지를 저장할 수 있습니다. 이는 Raw 이미지가 약 30MB의 메모리를 차지하기 때문입니다. iPhone 4 시리즈에있는 iOS6에서 앱을 테스트 할 때 유사한 메모리 경고를 발견했습니다. 기기가 iOS7로 업그레이드되었을 때이 경고가 계속 표시됩니다. iOS7의 iPhone 5 시리즈에서 테스트 할 때 메모리 경고가 없습니다.
바꾸다
[self presentViewController:imagePicker animated:YES completion:nil];
...에
[self presentViewController:imagePicker animated:YES completion:NULL];
나를 위해 문제를 해결했습니다.
'IT' 카테고리의 다른 글
| Git에 티타임이있는 이유는 무엇입니까? (0) | 2020.08.15 |
|---|---|
| Android 테마 배경색 설정 (0) | 2020.08.15 |
| 의존성 배치 컨테이너의 이점은 무엇입니까? (0) | 2020.08.15 |
| HTML 속성에 JSON을 저장하는 가장 좋은 방법은 무엇입니까? (0) | 2020.08.15 |
| ASP.NET 응용 프로그램을 라이브 서버에 어떻게 배포합니까? (0) | 2020.08.15 |