2013-12-11 4 views
0

을에 나는 다음과 같은 코드를 사용하고 있지 것은저장 이미지는 시뮬레이터에서 작동하지만 전화

-(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 층에서 스크린 샷을 저장 ,하지만 내 전화로 실행할 때 오류 메서드를 호출하고 아무 그림도 저장되지 않습니다.

이유가 누구인지 아시겠습니까? 칼

+1

을 내 새로운 앱에 대한 사진을 수 있습니다 그것은 NSLog에 오류를 알려주고 질문에 추가 할 수 있습니다. – danh

+0

다음은 NSLog 오류입니다. Error Domain = ALAssetsLibraryErrorDomain Code = -3310 "데이터를 사용할 수 없습니다."UserInfo = 0x1d58a1b0 {NSLocalizedRecoverySuggestion = 사진 응용 프로그램을 시작합니다. NSUnderlyingError = 0x1e8825f0 "데이터를 사용할 수 없음", NSLocalizedDescription = 데이터를 사용할 수 없음} – CarlosTheJackal

답변

2

대답은 휴대폰 자체에있다 아

..

나는 '-> 개인 정보 보호 - 설정> 사진'으로 이동했다 ..

+0

nice. 그 오류가 작동하는 인터넷 검색, 맞죠? 당신은 자신의 대답을 정확하게 표시 할 수 있습니다. – danh

+0

그래, 나는 오류를 봤어 .. 나는 NSLog에 오류 메시지도 배워야 만했다. 전에는 그렇게 해본 적이 없다. .. 올바른 트랙에 나를 붙여 주셔서 감사합니다. :-) – CarlosTheJackal

+0

@CarlosTheJackal 대답을 얻었다. –

관련 문제