iosiphoneobjective-cipaduidocumentinteraction

Done button click of UIDocumentInteractionController


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.


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,