1
내 앱에 파일 형식이 많아서 앱에 머무르는 동안 사용자가 파일을 열도록해야합니다. 예를 들어 사진 앨범의 PDF 파일과 사진이 있습니다. UIDocumentInteractionController
은 내가 원하는 파일 형식을 열 수 있음을 읽었습니다. 내 경로가 파일 경로입니다. 경로가 다음과 같은 사진 앨범의 이미지도 열 수 있습니까? "assets-library://"
? 갤러리에서 UIDocumentInteractionController를 사용하여 이미지 열기
- (void)setupDocumentControllerWithPath:(NSString *)path
{
if (path == nil || [path length] == 0) return;
NSURL* url = [NSURL fileURLWithPath:path];
if (self.docInteractionController == nil)
{
self.docInteractionController = [UIDocumentInteractionController interactionControllerWithURL:url];
self.docInteractionController.delegate = self;
}
else
{
self.docInteractionController.URL = url;
}
if ([path hasPrefix:@"assets-library"])
{
self.docInteractionController.UTI = @"jpeg";
CGRect rect = CGRectMake(x, y,w,h);
if (![self.docInteractionController presentOpenInMenuFromRect:rect inView:self.view animated:YES])
NSLog(@"Failed to open file in Asset");
}
else
{
if (![self.docInteractionController presentPreviewAnimated:YES])
NSLog(@"Failed to open document in Document Dir");;
}
url = nil;
}
을 내가 특정 경로에서 파일을 열고 자 할 때마다 나는 그것을 호출합니다. 자산 파일의 경우 코드에 로그 "자산에서 파일을 열지 못했습니다"를 입력하십시오.
을 시도 했습니까? 어떻게 된 거예요? – rmaddy
나는 노력했다. 문서 폴더의 파일에는 문제가 없습니다. 자산에있는 파일의 경우 아무 일도 일어나지 않습니다 ... – giuseppe
아무도 추측을 제안 할 수 없습니까? – giuseppe