2

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 ;
        }
    }
}
Dee
  • 1,887
  • 19
  • 47

2 Answers2

3

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];
Mal Curtis
  • 661
  • 7
  • 13
  • I am using this code, but Xcode is giving me a problem. For some reason it is forcing me to refer to docController in the .m file as "_docController" in order to compile. All works fine when I do this, just curious as to why it differs from your solution. Thanks. – njtman Sep 26 '13 at 13:05
  • It looks like I just found the answer to my own question. Look here http://stackoverflow.com/a/14188856/1015387 – njtman Sep 26 '13 at 13:07
2

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

Lupos
  • 31
  • 4