comment choisir un file PDF dans IOS

J'ai cherché en ligne et GitHub et ne pouvais pas find un moyen de sélectionner correctement un PDF dans IOS comme avec une image ou une video. Par exemple, je peux ouvrir et sélectionner une photo (select la photo avec d'autres methods qui la possèdent) comme ceci:

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

J'ai essayé ceci:

 // 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]; 

Mais j'ai une erreur ici:

 #import <UIKit/UIKit.h> #import "AppDelegate.h" int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSSsortingngFromClass([AppDelegate class])); } } 

Avec cette sortie d'erreur:

 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 

Y at-il quelque chose de similaire à choisir des photos, mais seulement pour les PDF?

1- Il n'y a pas de contrôle natif pour UIImagePicker qui vous permet de choisir un PDF.

2- Vous n'avez pas access aux files PDF dans l'iphone car contrairement à Android, il n'y a pas d'explorateur.

Si vous souhaitez save des files PDF, vous devez les save en tant que données de base dans votre application, et vous devez créer UITableView ou UICOllectionView avec une vue pour chaque PDF en tant que sélecteur de PDF. Gardez à l'esprit que cela restra dans le context de l'application car IOS se comporte différemment d'Android