有没有人有关于如何以编程方式或使用segue为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.");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2388 次 |
| 最近记录: |