use*_*452 1 uiviewcontroller ios 3dtouch mfmailcomposeviewcontroller
在我的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;
}
Run Code Online (Sandbox Code Playgroud)
这成功地允许我在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];
}
Run Code Online (Sandbox Code Playgroud)
但是,邮件编写器永远不会出现.请帮忙.
Ror*_*nel 10
问题可能是在显示Peek视图时视图层次结构不正常.
尝试使用根视图控制器来呈现选择器:
[[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:picker animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)