iphoneシミュレータのMFMailComposeViewController
から電子メールを送信するテスト方法はありますか?シミュレータでMFMailComposeViewControllerをテストする方法
1
A
答えて
-4
読むSending mail with MFMailComposeViewController
まずMessageUIフレームワークが含まAN 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を電話機にインストールしてテストします。
しかし、あなたのAPPが行うことができます/制御する/シミュレータで指定することができます。 [送信]ボタンを押した後のすべてがAppleであるため、 が正常に機能しているとみなすことができます。
4
ありませんあなたは我々は次のように限られたものをテストすることができます(私はあなたのメールが配信されないという意味で)...シミュレータ上でそれをテストすることはできません:ビューがものになるかどうか、何をするとき、ユーザーがクリック起こりますキャンセルボタンなど...
メールが配信されたかどうかをテストするには、デバイスを使用する必要があります。あなたの設定には何らかのメール(例:gmail)が設定されている必要があります。
関連する問題
- 1. MFMailComposeViewControllerでToToRecipientsを設定する方法
- 2. iOS 4.0シミュレータとiOS 5.1でiOSアプリケーションをテストする方法
- 3. iOSシミュレータでiPad Proをテストする方法
- 4. シミュレータでさまざまなiOSesをテストする方法
- 5. CarPlayシミュレータでiOSアプリケーションをテストする方法
- 6. iOSシミュレータでダイナミックタイプ(より大きいフォントサイズ)をテストする方法
- 7. シミュレータのCFBundleDocumentTypesをテストする
- 8. iOSシミュレータでSMSをテストする
- 9. iOS 10シミュレータでIFAをテストする
- 10. iOSシミュレータとデバイスでNSFileProtectionCompleteをテストする
- 11. テスト間でiOSシミュレータをリセットする
- 12. シミュレータUIテスト
- 13. シミュレータで「合理化されたIDフロー」をテストする方法は?
- 14. ONVIFウェブサービスをテストするためのシミュレータ
- 15. iOSシミュレータでフルスクリーンショットを撮る方法
- 16. iOS:デバイス対シミュレータのテスト方法が25倍遅い
- 17. MFMailComposeViewControllerは実際にはシミュレータからのsendmailを想定していますか?
- 18. MFMailComposeViewControllerから電子メールアドレスを取得する方法
- 19. iOSシミュレータでMFMailComposeViewControllerをモックします。ちょうど作曲家を表示する必要があります
- 20. MFMailComposeViewController
- 21. xamarian.formsでMac用Visual StudioのiOSシミュレータ/ Androidシミュレータを使用する方法
- 22. コマンドラインでxcodebuildテストを実行するときにシミュレータを表示
- 23. xcodeシミュレータでipad 2カメラをテストするIOS 5
- 24. シミュレータのディレクトリを見つける方法
- 25. MFMailComposeViewControllerを押すviewController
- 26. シミュレータではなく物理的なiPhoneでテストするiPhoneアプリケーション
- 27. デバイス上のMFMailComposeViewControllerを開くことができません。シミュレータで動作します。
- 28. CSSとHTMLをMFMailComposeViewControllerで使用する
- 29. シミュレータを使用しないAppium iOSテスト
- 30. xcode 4.1のprevios iosバージョンでシミュレータを使用してiphoneアプリをテストする方法
あなたの答えのためのおかげで、しかし、あなたは違った私の質問を理解し、私は意味:テストする方法MFMailComposeViewControllerが本当に送信ボタンを押した後、電子メールかを送ったかどうか!!?電子メールをチェックアウトしたときに、そのコンポーザーから(シミュレータを使用して)送信された電子メールを見つけることができなかったので、間違った質問に答えることができます。 – JaHelia
-1疑問は、シミュレータでメールコントローラをテストする方法でした。答えは、コードを書く方法を示していますが、メールコントローラがシミュレータで動作しないため、テストを許可しません。 – Lee