سؤال

I tried to open a pdf file with the "Open in" menu, but when I create it, the code crash when I call the presentOpenInMenuFromBarButtonItem method

UIDocumentInteractionController * controller;
        controller = [UIDocumentInteractionController interactionControllerWithURL:fileUrl];
        controller.delegate = self;

        [controller presentOpenInMenuFromBarButtonItem:_openInBBItem animated:YES];

There is no error message.

Can you help me ?

هل كانت مفيدة؟

المحلول

The solution is to keep a reference on the UIDocumentInteractionController.

.h

@property UIDocumentInteractionController* interact;

.m

_interact = [UIDocumentInteractionController interactionControllerWithURL: fileUrl];
_interact.delegate = self;
[_interact presentOpenInMenuFromBarButtonItem: _openInBBItem animated:YES];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top