2016-08-10 2 views
0

온라인 및 GitHub를 검색하여 이미지 또는 비디오와 같이 IOS에서 PDF를 올바르게 선택할 수있는 방법을 찾지 못했습니다. 예를 들어, 나는 열고이 같은 사진을 (를 hadle 다른 방법으로 사진을 선택)을 선택할 수 있습니다 :이 시도했습니다IOS에서 PDF 파일을 선택하는 방법

self.logoImagePicker = [[UIImagePickerController alloc] init]; 
self.logoImagePicker.delegate = self; 
[self.logoImagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; 
[self presentViewController:self.logoImagePicker animated:YES completion:nil]; 

:

// Present PDF;s from which to choose 
UIDocumentInteractionController *pdfPicker = [[UIDocumentInteractionController alloc] init]; 
pdfPicker.delegate = self; // ensure you set the delegate so when a PDF is chosen the right method can be called 

[self presentViewController:pdfPicker animated:YES completion:nil]; 

을하지만 난 여기에 오류가 :

2016-08-10 07:40:59.190 Whats New[55195:1962738] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'No available types for source 0' 
*** First throw call stack: 
(
0 CoreFoundation      0x00ef1494 __exceptionPreprocess + 180 
1 libobjc.A.dylib      0x0060fe02 objc_exception_throw + 50 
2 UIKit        0x01eb9dc2 -[UIImagePickerController mediaTypes] + 0 
3 Whats New       0x000c6253 -[SellerHomePageViewController choosePdfBtn:] + 243 
4 libobjc.A.dylib      0x006240b5 -[NSObject performSelector:withObject:withObject:] + 84 
5 UIKit        0x01ab0e38 -[UIApplication sendAction:to:from:forEvent:] + 118 
6 UIKit        0x01ab0db7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64 
7 UIKit        0x01c54f3b -[UIControl sendAction:to:forEvent:] + 79 
8 UIKit        0x01c552d4 -[UIControl _sendActionsForEvents:withEvent:] + 433 
9 UIKit        0x01c542c1 -[UIControl touchesEnded:withEvent:] + 714 
10 UIKit        0x02037d2e _UIGestureRecognizerUpdate + 12763 
11 UIKit        0x01b30efd -[UIWindow _sendGesturesForEvent:] + 1559 
12 UIKit        0x01b325b6 -[UIWindow sendEvent:] + 1137 
13 UIKit        0x01ad3be8 -[UIApplication sendEvent:] + 266 
14 UIKit        0x01aa8769 _UIApplicationHandleEventQueue + 7795 
15 CoreFoundation      0x00e03e5f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 
16 CoreFoundation      0x00df9aeb __CFRunLoopDoSources0 + 523 
17 CoreFoundation      0x00df8f08 __CFRunLoopRun + 1032 
18 CoreFoundation      0x00df8846 CFRunLoopRunSpecific + 470 
19 CoreFoundation      0x00df865b CFRunLoopRunInMode + 123 
20 GraphicsServices     0x05aa5664 GSEventRunModal + 192 
21 GraphicsServices     0x05aa54a1 GSEventRun + 104 
22 UIKit        0x01aaeeb9 UIApplicationMain + 160 
23 Whats New       0x000d1e4a main + 138 
24 libdyld.dylib      0x03cc4a25 start + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
: 출력이 오류로

#import <UIKit/UIKit.h> 
#import "AppDelegate.h" 

int main(int argc, char * argv[]) { 
@autoreleasepool { 
    return UIApplicationMain(argc, argv, nil,  NSStringFromClass([AppDelegate class])); 
} 
} 

사진을 선택하는 것과 비슷하지만 PDF 만 사용할 수 있습니까?

+0

그리고 어디에 있어야합니다. PDF 파일을? 그리고 왜 그것들은'UIImagePickerController'에서 사용할 수 있습니까? – Larme

+0

사과 드리며, 잘못된 것을 붙여 넣으십시오. –

+0

'alloc' /'init'이 아닌'+ interactControllerWithURL :'을 호출해야합니다. – Larme

답변

0

1- PDF를 선택할 수있는 UIImagePicker와 같은 네이티브 컨트롤이 없습니다.

2 안드로이드와 달리 아이폰에는 PDF 파일이 없으므로 탐색기가 없습니다.

PDF를 저장하려면 응용 프로그램에서 coreData로 저장해야하며 PDF 선택 도구로 각 PDF에 대한보기가있는 UITableView 또는 UICOllectionView를 만들어야합니다. IOS가 다르게 안드로이드와 행동하는 것처럼 이것은 애플 리케이션의 컨텍스트 내에서 유지됩니다 염두에 두십시오

+0

거기에 탐색기 수있는 GitHub 무엇입니까? –

+0

에는이 있는데 그것을 허용하지 않는, tuhs :(그래서 바보 –

+1

신 이잖아,이 스레드가 종료 할 수 있도록 정확한 답변으로이를 표시 할 수 있습니다! 도움을 주셔서 감사하십시오 :) 내가 전에 할 –

관련 문제