我想显示警告消息当设备上没有配置邮件时。但是当我从文档交互单击邮件时,它只是简单地关闭控制器,以下两个委托方法都不会调用。请参阅图像以便更好地理解。
请帮忙。在此先感谢
- (void)openAppList:(FileInfo *)fileinfo {
NSURL *fileURL = [NSURL fileURLWithPath:fileinfo.fullName];
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
[interactionController retain];
interactionController.delegate = self;
BOOL present = [interactionController presentOptionsMenuFromRect:CGRectZero inView:self.tabBarController.view animated:YES];
if (!present) {
[MainteOrErrorDialog initWithErrorCode:kAlertNotOpenInFileId filename:fileInfo.filename target:nil action:nil];
} else {
[interactionController retain];
}
}
#pragma UIDocumentInteractionDelegate
- (void)documentInteractionController:(UIDocumentInteractionController *)controller
willBeginSendingToApplication:(NSString *)application
{
}
- (void)documentInteractionController:(UIDocumentInteractionController *)controller
didEndSendingToApplication:(NSString *)application
{
}
答案 0 :(得分:0)
不幸的是,您无法通过UIDocumentInteractionController与Mail委托进行真正的交互。 UIDocumentInteractionController极其局限于您可以使用它支持的所有应用程序的属性和属性,您甚至无法将邮件消息正文设置为自定义消息。实际上,在iOS 6.0中不推荐使用documentInteractionController:canPerformAction:
,因为Apple正在向UIActivityViewController发展。 They're own deprecated statement是:
应用应使用UIActivityViewController进行操作
或者,您可以使用UIActivityViewController。
解决这个问题,实现UIActivityViewController,它们都支持相同的应用程序并检查用户是否可以发送电子邮件,如果没有,则从菜单中排除Mail:
if ([MFMailComposeViewController canSendMail]) {
NSArray *shareItems;
shareItems = @[[Config emailMessage], snapshot]; //emailMessage is an NSString containing the body of the mail or mms message located in a different VC
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:shareItems applicationActivities:nil];
[activityController setCompletionWithItemsHandler:(UIActivityViewControllerCompletionWithItemsHandler)^(NSString *string, BOOL completed) {
}
[self presentViewController:activityController animated:YES completion:nil];
} else {
NSArray *shareItems;
shareItems = @[[Config emailMessage], snapshot]; //emailMessage is an NSString containing the body of the mail or mms message located in a different VC
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:shareItems applicationActivities:nil];
activityController.excludedActivityTypes = @[UIActivityTypeMail];
[activityController setCompletionWithItemsHandler:(UIActivityViewControllerCompletionWithItemsHandler)^(NSString *string, BOOL completed) {
}
[self presentViewController:activityController animated:YES completion:nil];
}