Question

I am downloading a PDF file from an online server and save it to my the App's Sandbox then view it in iBooks.

The iBooks viewing is what i am struggling now. I tried this code:

    UIDocumentInteractionController *docController = [UIDocumentInteractionController interactionControllerWithURL:url];

    docController.delegate = self;

    [docController presentOpenInMenuFromRect:savePDF.frame inView:self.view animated:YES];
    [docController dismissMenuAnimated:YES];

Still gor no chance, It is running but the popover is being dismissed right away after it was presented. But when I deleted [docController dismissMenuAnimated:YES]; it gives me an error saying '-[UIPopoverController dealloc] reached while popover is still visible.'

What could be the problem?

Was it helpful?

Solution

The problem is that your UIDocumentInteractionController is being released right after being presented, due to the variable docController no longer being in scope.

To prevent that, you should create a strong property or an instance variable and store your UIDocumentInteractionController in there. That way, the UIDocumentInteractionController will stick around until you release the object controlling it, which should be long enough for the user to make a selection...

OTHER TIPS

I tried everything again and again but finally got the [UIPopoverController dealloc] reached while popover is still visible error to go away and all is working by doing this:

Go to your Project Build Phases --> then Compile Sources --> choose the .m that you are having the issue with and double click the Compiler Flag and add -fobjc-arc then clean and build your app.

Again this wont work for everyone and may not be the right answer but it may also help a few others having the same issue I had.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top