0

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.

Piyush
  • 158
  • 2
  • 14

2 Answers2

0

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,

WDUK
  • 18,870
  • 3
  • 64
  • 72
  • What I want is only to preview the document(any type i.e image, pdf, etc) and don't want user to share it. So, need to hide this "Share" button. – Piyush Oct 25 '13 at 12:45
  • 1
    You could try rendering it within a UIWebView, this way you have a bit more control. – WDUK Oct 25 '13 at 13:22
  • @WDUK, is it possible to get Share button click action on document preview , I have to track user clicked action on share button . – Jaywant Khedkar Jul 03 '19 at 06:22
0

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")
}
Sudhi 9135
  • 745
  • 8
  • 17