在我的应用程序的Peek视图的视图控制器中,我具有:
- (NSArray*)previewActionItems {
/
UIPreviewAction *action1 = [UIPreviewAction actionWithTitle:@"Post to Facebook" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
}];
UIPreviewAction *action2 = [UIPreviewAction actionWithTitle:@"Message" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
}];
UIPreviewAction *action3 = [UIPreviewAction actionWithTitle:@"Email" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
[self displayComposerSheet];
}];
/
NSArray *actions = @[action1, action2, action3];
/
return actions;
}
这成功地使我能够在3D Touch之后提起预览动作。 displayComposerSheet是:
-(void)displayComposerSheet
{
NSLog(@"Mail Button Pressed");
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Check out this article from Fritch"];
/
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"];
[picker setToRecipients:toRecipients];
/
NSString *emailBody = self.finalObject.articleImage;
[picker setMessageBody:emailBody isHTML:YES];
[self presentViewController:picker animated:YES completion:nil];
[picker release];
}
但是,永远不会出现邮件编辑器。请帮忙。
最佳答案
问题可能是显示Peek视图时视图层次结构不正常。
尝试使用根视图控制器来呈现选择器:
[[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:picker animated:YES completion:nil];
关于ios - Mail Composer无法从UIPreviewAction启动,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33020185/