Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIDocumentInteractionController Open Menu Cancelled Callback

I am currently developing an application specifically for iOS7 that utilizes UIDocumentInteractionController open in menu and need a method that notifies me when a user cancels and does not choose an available option.

UIDocumentInteractionControllerDelegate offers:

- (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *) controller

but this does not specify whether the user tapped one of the available options or cancel.

Any ideas?

like image 426
morcutt Avatar asked Feb 08 '14 00:02

morcutt


1 Answers

NOTE: This will not work for iOS 8 anymore, only iOS7 and earlier

To determine whether the user has canceled the menu or selected an option, you have to make use of the following delegate methods:

1-

- (void)documentInteractionController:(UIDocumentInteractionController *)controller
           didEndSendingToApplication:(NSString *)application
{
    //get called only when the user selected an option and then the delegate method bellow get called
    // Set flag here _isOptionSelected = YES;
    _isOptionSelected = YES;
}

2-

- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller
{
    //called whether the user has selected option or not
    // check your flag here 
    if(_isOptionSelected == NO) {
        //the user has canceled the menu
     }
    _isOptionSelected = NO;
}

iOS 8

For iOS 8 and above, use this method instead of the one in step 2:

- (void)documentInteractionController:(UIDocumentInteractionController *)controller
           didEndSendingToApplication:(NSString *)application
like image 199
Basheer_CAD Avatar answered Nov 15 '22 19:11

Basheer_CAD