有没有人有一个体面的教程,如何以编程方式或与segues实现邮件编辑器的ios 5?我在网上找到的大多数教程都来自旧的iOS版本。谢谢!用于iOS 5的MFMailComposeViewController:教程或示例
0
A
回答
5
你可以做这样的事情:
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:@"[email protected]"]];
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.");
+0
之前做这个东西,你必须检查[MFMailComposeViewController canSendMail]否则你会遇到崩溃的情况下,邮件没有设置 –
2
首先,你必须添加“MFMailComposeViewControllerDelegate”的接口部分。
你也需要添加过程,以获得响应用户点击“发送按钮”
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result) {
case MFMailComposeResultSent:
NSLog(@"You sent the email.");
break;
case MFMailComposeResultSaved:
NSLog(@"You saved a draft of this email");
break;
case MFMailComposeResultCancelled:
NSLog(@"You cancelled sending this email.");
break;
case MFMailComposeResultFailed:
NSLog(@"Mail failed: An error occurred when trying to compose this email");
break;
default:
NSLog(@"An error occurred when trying to compose this email");
break;
}
[self dismissViewControllerAnimated:YES completion:NULL];
}
相关问题
- 1. iPhone:json的教程在ios 5
- 2. 如何推送MFMailComposeViewController? (iOS 5)
- 3. 最近的iOS测验教程和/或代码示例
- 4. slider中的滑块示例或教程
- 5. 寻求libusb_device教程和/或示例
- 6. 寻找WCF basicHttpBinding https教程或示例
- 7. Google Guava Service教程或示例?
- 8. Dart Web组件教程或示例
- 9. SlickGrid和asp.net示例或教程
- 10. UIManagedDocument示例/教程
- 11. Restlet教程示例
- 12. Hunspell的示例/教程
- 13. Enthought的EPD示例教程
- 14. 的HtmlHelper在教程示例
- 15. msdn“Direct3D教程Win32示例”教程2
- 16. 教程 - 在asp.net的MVC 4或5
- 17. TopLink的示例和教程
- 18. Ember.js的教程和示例?
- 19. MFMailComposeViewController不填充收件人在ios 5
- 20. 适用于Metropolis的示例/教程使用PyMC的图像
- 21. 用于Kurento的iOS客户端教程
- 22. 教程或用于社交共享的PHP队列系统的示例
- 23. 有没有关于如何使用Naver的Line URL ScheemE的示例或教程?
- 24. RoR:SaaS示例(代码/教程)?
- 25. Ios MFMailComposeViewController不会显示
- 26. 用例教程
- 27. Rails教程示例应用程序6.26
- 28. Antlr4 C#应用程序教程/示例
- 29. 关于使用XA事务的任何教程,示例或经验?
- 30. 有关于如何使用OpenGL纹理模糊的教程或简化示例?
的实施并没有改变多少,如果在所有之后。它只是创建视图控制器并在最简单的情况下以模态方式调用它。基本上就像你会模式地推控制器,而不使用iOS故事板。 –