在我的应用程序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:@"friend@example.com"];
[picker setToRecipients:toRecipients];
/
NSString *emailBody = self.finalObject.articleImage;
[picker setMessageBody:emailBody isHTML:YES];
[self presentViewController:picker animated:YES completion:nil];
[picker release];
}
然而,邮件作曲家永远不会出现。请帮忙。
答案 0 :(得分:10)
问题可能是显示Peek视图时视图层次结构不正常。
尝试使用根视图控制器来显示选择器:
[[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:picker animated:YES completion:nil];