UIDocumentInteractionController打开菜单取消回调 [英] UIDocumentInteractionController Open Menu Cancelled Callback

查看:1251
本文介绍了UIDocumentInteractionController打开菜单取消回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个专门用于iOS7的应用程序,该应用程序使用菜单中打开的UIDocumentInteractionController,并需要一种方法,当用户取消并不选择可用选项时通知我。



UIDocumentInteractionControllerDelegate提供:

   - (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *)controller 



,但这并不指定用户是否点击了其中一个可用选项或取消。



任何想法?

解决方案

注意:这不适用于iOS 8 >



要确定用户是否取消了菜单或选择了某个选项,必须使用以下委派方法:



1-

   - (void)documentInteractionController:(UIDocumentInteractionController *)controller 
didEndSendingToApplication:(NSString *)application
{
//仅当用户选择一个选项然后调用委托方法时才调用
// Set flag here _isOptionSelected = YES;
_isOptionSelected = YES;
}

2-

   - (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller 
{
//调用用户是否选择了选项
检查您的标志
if(_isOptionSelected == NO){
//用户已取消菜单
}
_isOptionSelected = NO;
}

iOS 8



对于iOS 8及以上版本,使用此方法代替步骤2中的方法:

  (void)documentInteractionController:(UIDocumentInteractionController *)controller 
didEndSendingToApplication:(NSString *)application


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?

解决方案

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

这篇关于UIDocumentInteractionController打开菜单取消回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆