Dee
Dee

Reputation: 1897

iPad application crashes when I call UIDocumentInteractionController method "presentOpenInMenuFromRect: inView: animated:"

Here is my code: In iPad it is crashing in iPhone the list is appearing but the selected application is not getting open.

- (void)openIn:(NSURL *)fileFullPath {
    docController = [UIDocumentInteractionController interactionControllerWithURL:fileFullPath];
    [docController setDelegate:self];

    BOOL isOpen = [docController presentPreviewAnimated:YES];

    if (isOpen == NO) {
        BOOL isOpenIn = [docController presentOpenInMenuFromRect:CGRectMake(300, 300, 100, 100) inView:self.view animated:NO];

        if(isOpenIn == NO) {
            return ;
        }
    }
}

Upvotes: 3

Views: 2129

Answers (2)

Mal Curtis
Mal Curtis

Reputation: 695

As per Lupos' answer, defining an instance variable for my docController fixed the same issue that you were seeing.

I don't have enough reputation to comment on his answer.

// In your .h file
@property (nonatomic, strong) UIDocumentInteractionController *docController;

// When calling in your .m
docController = [UIDocumentInteractionController interactionControllerWithURL:fileFullPath];

Upvotes: 3

Lupos
Lupos

Reputation: 31

If it is still relevant the problem is probably that the UIDocumentInteractionController is released from memory. Try to define it as an instance variable.

Upvotes: 2

Related Questions