我目前正在开发一个专门针对 iOS7 的应用程序,该应用程序利用在菜单中打开的 UIDocumentInteractionController 并需要一种方法来在用户取消且未选择可用选项时通知我。
UIDocumentInteractionControllerDelegate 提供:
- (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *) controller
但这并没有指定用户是否点击了可用选项之一或取消。
有任何想法吗?
注意:这不再适用于 iOS 8,仅适用于 iOS7 及更早版本
要确定用户是否取消了菜单或选择了某个选项,您必须使用以下委托方法:
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
对于 iOS 8 及更高版本,请使用此方法而不是步骤 2 中的方法:
- (void)documentInteractionController:(UIDocumentInteractionController *)controller
didEndSendingToApplication:(NSString *)application
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)