2013-07-08 3 views
4

사용자가 Instagram, Facebook 및 로컬 사진을 내 앱으로 가져올 수 있도록 grabKit을 사용하고 있습니다. 문제는 사진이 로컬 일 때입니다. 이 경우 사용자가 사진을 선택하면 작동하는 방법을 사용합니다.ALAsset을 사용하는 GRKPhoto의 UIImage

내가 그렇게하기 위해 발견 된 표준 코드는 다음과 같다 :

 
- (void)picker:(GRKPickerViewController*)picker didSelectPhoto:(GRKPhoto *)photo{ 

    [popover dismissPopoverAnimated:YES]; 

    GRKImage *originalImage = [photo originalImage]; 

    NSLog(@" the URL of the original image of the first selected photo is : %@", originalImage.URL); 
    NSLog(@" the size of this image is : %d x %d ", originalImage.width, originalImage.height); 

    // If the url begins with assets-library:// 
    if ([[originalImage.URL absoluteString] hasPrefix:@"assets-library://"]){ 

     // Instantiate a library 
     ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init]; 

     // Ask for the "Asset" for the URL. An asset is a representation of an image in the Photo application. 
     [library assetForURL:originalImage.URL 
       resultBlock:^(ALAsset *asset) { 

        // Here, we have the asset, let's retrieve the image from it 
        CGImageRef imgRef = [[asset defaultRepresentation] fullResolutionImage]; 

        // From the CGImage, let's build an UIImage 
        UIImage * fullResImage = [UIImage imageWithCGImage:imgRef]; 

        NSLog(@" The UIImage for URL %@ is %@", originalImage.URL, fullResImage); 

       } failureBlock:^(NSError *error) { 
        // Something wrong happened. 
       }]; 
} 

디버깅을함으로써을, 나는 응용 프로그램 충돌이 나는에서 ALAsset, ERGO에서 CGImageRef을 얻을 때 발견 이 줄은 CGImageRef imgRef = [[asset defaultRepresentation] fullResolutionImage];입니다. 내 문제를 해결하는 데 도움이 될 수 있습니다 경우

, 내가 콘솔에서 얻을 메시지는 다음과 같습니다 시간과 관심을

 
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 653]' 

*** First throw call stack: 

(0x42f8012 0x2ad9e7e 0x42f7deb 0x161ee0b 0x161efa5 0x161f6eb 0x174fe53 0x18191c0 0x181941a 0x21fad 0x219f1 0x13de70 0xf3c03 0x1c0f42f 0x1c21182 0x1c21394 0x2aed705 0x181b93c 0x181b9ac 0x2aed705 0x181b93c 0x181b9ac 0x19d51d3 0x42c0afe 0x42c0a3d 0x429e7c2 0x429df44 0x429de1b 0x3b9d7e3 0x3b9d668 0x170dffc 0x69432 0x30f5) 

libc++abi.dylib: terminate called throwing an exception 

감사합니다!

답변

2

보통 CALayerInvalidGeometryNAN은 CALayer 프레임의 잘못된 설정으로 인한 것이며 view.frame으로 설정할 수 있습니다. 어쩌면 레이어 위치/변형이 잘못 설정된 것일 수 있습니다. 이 작업을 직접 수행하지 않으므로 Grabkit의 버그 인 것 같습니다. 파일 here.

F3을 사용하여 CGImageRef imgRef = [[asset defaultRepresentation] fullResolutionImage]; 내부로 들어가면 충돌에 대한 자세한 정보를 Grabkit에 제공 할 수 있습니다.