2015-01-22 3 views
0

Я хочу показать сообщение оповещения, когда на устройстве не настроено почтовое сообщение. Но когда я нажимаю «Почта» из взаимодействия с документом, он просто просто увольняет контроллер, ни один из двух следующих делегатов метод вызовет. Пожалуйста, обратитесь к изображению для лучшего понимания.Метод делегата UIDocumentInteractionController не вызывается при нажатии на почтовую кнопку

Пожалуйста, помогите. Спасибо заранее

- (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 
{ 

} 

enter image description here

ответ

0

К сожалению, вы не можете реально взаимодействовать с почтой через делегатов UIDocumentInteractionController. UIDocumentInteractionController чрезвычайно ограничен тем, что вы можете делать со свойствами и атрибутами всех приложений, которые он поддерживает, вы даже не можете настроить тело сообщения почты на настраиваемое сообщение. Фактически, documentInteractionController:canPerformAction: устарел в iOS 6.0, потому что Apple двигалась в направлении UIActivityViewController. They're own deprecated statement является:

приложения должны использовать UIActivityViewController для действий


Так в качестве альтернативы, с UIActivityViewController вы можете.

Произведение вокруг этого, осуществлять UIActivityViewController, они оба поддерживают те же приложения и убедитесь, что пользователь может отправить электронную почту, если не исключить почты из меню:

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]; 
} 
Смежные вопросы