을에 나는 다음과 같은 코드를 사용하고 있지 것은저장 이미지는 시뮬레이터에서 작동하지만 전화
-(void) takeScreenshot {
[self turnAllNotesBlack];
CCScene *scene = [[CCDirector sharedDirector] runningScene];
CCNode *n = [scene.children objectAtIndex:0];
UIImage *img = [self screenshotWithStartNode:n];
//NSParameterAssert(img);
UIImageWriteToSavedPhotosAlbum(img,
self,
@selector(image:finishedSavingWithError:contextInfo:),
nil);
[self resetIlluminatedNotes];
}
-(void)image:(UIImage *)image
finishedSavingWithError:(NSError *)error
contextInfo:(void *)contextInfo
{
if (error) {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"Save failed"
message: @"Failed to save image"
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
그것은 시뮬레이터에서 잘 작동합니다 .. 카메라 롤에적인 Cocos2D 층에서 스크린 샷을 저장 ,하지만 내 전화로 실행할 때 오류 메서드를 호출하고 아무 그림도 저장되지 않습니다.
이유가 누구인지 아시겠습니까? 칼
을 내 새로운 앱에 대한 사진을 수 있습니다 그것은 NSLog에 오류를 알려주고 질문에 추가 할 수 있습니다. – danh
다음은 NSLog 오류입니다. Error Domain = ALAssetsLibraryErrorDomain Code = -3310 "데이터를 사용할 수 없습니다."UserInfo = 0x1d58a1b0 {NSLocalizedRecoverySuggestion = 사진 응용 프로그램을 시작합니다. NSUnderlyingError = 0x1e8825f0 "데이터를 사용할 수 없음", NSLocalizedDescription = 데이터를 사용할 수 없음} – CarlosTheJackal