iphone - 适用于 iOS 5 的 MFMailComposeViewController : Tutorial or Example

标签 iphone ios ios5

有没有人有关于如何以编程方式或使用 segues 为 ios 5 实现邮件编辑器的体面教程?我在网上找到的大部分教程都来自旧的 iOS 版本。谢谢!

最佳答案

你可以这样做:

if([MFMailComposeViewController canSendMail])
{
    MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
    [mailController setMailComposeDelegate:self];
    [mailController setSubject:@"Mail Subject!"];
    [mailController setMessageBody:@"Here is your message body" isHTML:NO];
    [mailController setToRecipients:[NSArray arrayWithObject:@"yourrecipent@domain.com"]];

    NSData *imageData = UIImageJPEGRepresentation(imageToUpload, 1.0f);
    if(imageData.length)
    {
        [mailController addAttachmentData:imageData mimeType:@"image/jpeg" fileName:@"Your_Photo.jpg"];
        [self presentModalViewController:mailController animated:YES];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invalid Image" message:@"The image couldn't be converted." delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Okay", nil];
        [alert show];
    }
}
else NSLog(@"Hah. No mail for you.");

关于iphone - 适用于 iOS 5 的 MFMailComposeViewController : Tutorial or Example,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12394928/

相关文章:

iphone - 非 ARC 和弱属性 - ios 5

iphone - iOS remoteControlReceivedWithEvent 未调用

iphone - NSString 到 UIImage 绘图问题

ios - 跨多个 subview 传递 UITouch * 的正确方法是什么?

ipad - 如何使用 Xcode Storyboards 创建 Popovers

iOS 5/6 Twitter 无对话分享

iphone - 如何在 subview 中设置触摸事件?

ios - 核心数据 : Fetch and group different entities based on date created

ios - 魔法记录 saveWithBlock : not saving

html - 在 iOS Safari 中以 24 小时格式显示时间输入类型