有没有一种方法来测试iPhone模拟器从发送电子邮件MFMailComposeViewController
?如何测试MFMailComposeViewController在模拟器
1
A
回答
-4
阅读Sending mail with MFMailComposeViewController
首先包括MessageUI框架工具MFMailComposeViewControllerDelegate。
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>
@interface MainViewController : UIViewController <MFMailComposeViewControllerDelegate> {
}
然后实现一个像这样的方法来移除邮件控制器的委托方法。
- (IBAction)pressentMailController:(id)sender {
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Test subject!"];
// Set up the recipients.
/*NSArray *toRecipients = [NSArray arrayWithObjects:@"[email protected]",
nil];
NSArray *ccRecipients = [NSArray arrayWithObjects:@"[email protected]",
@"[email protected]", nil];
NSArray *bccRecipients = [NSArray arrayWithObjects:@"[email protected]",
nil];
[picker setToRecipients:toRecipients];
[picker setCcRecipients:ccRecipients];
[picker setBccRecipients:bccRecipients];
*/
// Attach an image to the email.
/*NSString *path = [[NSBundle mainBundle] pathForResource:@"ipodnano"
ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"image/png"
fileName:@"ipodnano"];
*/
// Fill out the email body text.
NSString *emailBody = @"It is raining in sunny California!";
[picker setMessageBody:emailBody isHTML:NO];
// Present the mail composition interface.
[self presentModalViewController:picker animated:YES];
[picker release]; // Can safely release the controller now.
}
// The mail compose view controller delegate method
- (void)mailComposeController:(MFMailComposeViewController *)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError *)error
{
[self dismissModalViewControllerAnimated:YES];
}
该代码允许添加收件人,正文,主题和附件。根据需要取消注释。
1
实际邮件发送是不可能的从模拟器。 在手机上安装应用程序以测试该应用程序。
但是你可以检验一切,你的APP可以做/控制/在模拟器中指定。在按下发送按钮后 一切都是苹果,所以你可以认为是 工作正常。
4
不,你不能测试它在模拟器...(我的意思是你的邮件将不会传递)。我们将能够测试有限的东西,如:视图将会如何,会发生什么用户点击时在取消按钮等等
测试邮件是否交付与否,你必须使用的设备。该设备应该在您的设置中配置一些邮件(例如:Gmail)。
相关问题
- 1. applicationWillResignActive如何在iPhone模拟器测试
- 2. 单测试类模拟器
- 3. RISCV测试模拟器
- 4. Ipad测试模拟器
- 5. 测试:模拟模拟
- 6. 如何在Angular2测试中模拟Observable.throw?
- 7. 如何在GWT测试中模拟
- 8. 如何模拟在Haskell中测试?
- 9. 如何在测试中模拟NavParams?
- 10. MFMailComposeViewController不会链接模拟器
- 11. 如何测试BOOT_COMPLETED广播接收器在模拟器中
- 12. 在模拟器中测试CFBundleDocumentTypes
- 13. 在iPad模拟器中测试MPMoviePlayerViewController
- 14. 在控制器测试模拟工厂
- 15. 在iOS 10模拟器中测试IFA
- 16. 在iOS模拟器中测试短信
- 17. 模拟CompletionException在测试
- 18. 如何在JUnit测试中(容器外部)模拟TransactionManager?
- 19. 如何在模拟器中测试Twitter iOS 5集成?
- 20. 如何在Android模拟器上测试多点触控?
- 21. 如何在Python单元测试中模拟外部服务器?
- 22. 如何在iPhone模拟器上测试MFMessageComposeViewController?
- 23. 如何在仪器测试中模拟活动依赖关系
- 24. 如何在模拟器中测试LinkedIn SDK?
- 25. 如何在模拟器上测试iOS麦克风的使用?
- 26. 如何在测试运行后让模拟器打开?
- 27. 如何在模拟器中测试不同的iOS
- 28. 如何在Web组件测试器中模拟全局变量
- 29. 如何测试在iPhone模拟器上添加注释
- 30. 如何在测试时更改默认的Xcode iphone模拟器
谢谢您的回答,但是,你明白我的问题不同,我的意思是:如何测试MFMailComposeViewController是否真正发送的电子邮件或不按发送键后!!?因为当我检查了我的电子邮件,我找不到从该作曲家发送的任何电子邮件(使用模拟器)我很抱歉混淆的话.. – JaHelia
-1回答错误的问题。问题是如何在模拟器中测试邮件控制器。答案显示了如何编写代码,但不允许测试,因为邮件控制器在模拟器中不起作用。 – Lee