首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MFMailComposeViewController -无法presentViewController

MFMailComposeViewController -无法presentViewController
EN

Stack Overflow用户
提问于 2013-08-16 07:02:22
回答 1查看 778关注 0票数 0

这是我的密码

代码语言:javascript
复制
-(IBAction)emailButtonPressed :(UIButton *)sender {

    if (![MFMailComposeViewController canSendMail]) {

        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"Mail has not been set up on this device" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [alertView show];

        return;
}

    NSString *targetFile = [self saveCompleteImage];

    MFMailComposeViewController *mailpicker = [[MFMailComposeViewController alloc] init];
    [mailpicker setMailComposeDelegate:self];

    NSString *mimeType = [StringHelper getMimeType:targetFile];
    [mailpicker addAttachmentData:[NSData dataWithContentsOfFile:targetFile] mimeType:mimeType fileName:[targetFile lastPathComponent]];

    [mailpicker setSubject:[self.currentDocument getNameForUntitled]];
    mailpicker.modalPresentationStyle = UIModalPresentationFormSheet;

    [self.presentedViewController presentViewController:mailpicker animated:YES completion:nil];
}

这不是在展示邮递员。请告诉我我哪里错了。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-16 07:07:26

此代码的问题是:

代码语言:javascript
复制
[self.presentedViewController presentViewController:mailpicker animated:YES completion:nil];

你需要使用:

代码语言:javascript
复制
[self presentViewController:mailpicker animated:YES completion:nil];

代码语言:javascript
复制
[self.presentingViewController presentViewController:mailpicker animated:YES completion:nil];

检查ModalViewControllers参考以了解presentedViewControllerpresentingViewController之间的区别

票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18267605

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档