• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

iphone - 发件人地址的 MFMailComposeViewController 问题

[复制链接]
菜鸟教程小白 发表于 2022-12-13 00:20:48 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我使用以下代码发送邮件:

- (IBAction)sendMailPressedid)sender
{
    Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
    if (mailClass != nil)
    {
        // We must always check whether the current device is configured for sending emails
        if ([mailClass canSendMail])
        {
            [self displayComposerSheet];
        }
        else
        {
            [self launchMailAppOnDevice];
        }
    }
    else
    {
        [self launchMailAppOnDevice];
    }
}

// Displays an email composition interface inside the application. Populates all the Mail fields.
-(void)displayComposerSheet
{
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;


    [picker setSubject:self.strMailSubject];

    // Attach pdf to the email
    NSURL *urlToLoad = [[NSBundle mainBundle] URLForResource:self.strSorce withExtension:self.strExtention];
    NSData *myData = [NSData dataWithContentsOfURL:urlToLoad];
    [picker addAttachmentData:myData mimeType"application/pdf" fileName:[NSString stringWithFormat"%@.%@", self.strSorce, self.strExtention]];

    //  [self presentModalViewController:picker animated:YES];
    [[Singleton sharedInstance] pushModalViewController:picker whereCurrentController:self animated:YES];
    [picker release];
}


// Dismisses the email composition interface when users tap Cancel or Send. Proceeds to update the message field with the result of the operation.
- (void)mailComposeControllerMFMailComposeViewController*)controller didFinishWithResultMFMailComposeResult)result errorNSError*)error
{
    // Notifies users about errors associated with the interface
    switch (result)
    {
        case MFMailComposeResultCancelled:
            break;
        case MFMailComposeResultSaved:
            break;
        case MFMailComposeResultSent:

            break;
        case MFMailComposeResultFailed:
            break;
        default:
            break;
    }

    [[Singleton sharedInstance] popModalViewControllerAnimated:YES];
}


// Launches the Mail application on the device.
-(void)launchMailAppOnDevice
{
    NSString *recipients = [NSString stringWithFormat"mailto:&subject=%@", self.strMailSubject];

    NSString *email = [NSString stringWithFormat"%@", recipients];
    email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}

我得到了这样的观点: enter image description here

但我需要这个 View (请只注意From字符串,不要注意图像)。

我不知道如何让 From 字符串出现

enter image description here



Best Answer-推荐答案


您可以在代码中为此使用 setCcRecipients:

关于iphone - 发件人地址的 MFMailComposeViewController 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14155897/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap