Question

Hello All
I did search for this, but didn't get anything useful.
I need to get "Done" button click action of UIDocumentInteractionController. Can anyone please guide me? I am making an app for iPhone & iPad both.

Update:- I also need to hide "Share" button at top right corner.

Thanks in advance.

Was it helpful?

Solution

You can determine whether a user has selected "Done" via the UIDocumentInteractionController's delegate. Simply:

@interface MyClass : NSObject <UIDocumentInteractionControllerDelegate>
...
@end

...

UIDocumentInteractionController* controller = ...;
controller.delegate = self;

...

- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
{
    NSLog(@"User has dismissed preview");
}

As for removing "Share", this isn't easy, and Apple suggest you should have it in all cases. This makes sense, if you're previewing a PDF, the user may very well wish to view it in a dedicated PDF reader, or to email it. If you don't want the ability to share due to business/security reasons, then you'll need to try and render the document yourself. How this is done depends on the document,

OTHER TIPS

For Swift 3.2

You can add this delegate method for performing operations on the click of done button in UIDocumentInteractionController.

func documentInteractionControllerDidEndPreview(_ controller: UIDocumentInteractionController) {
    print("Done Button called here")
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top