私はiOS開発を夢中にしており、添付ファイル付きの電子メールを送信するためのMFMailComposeViewControllerクラスについてよく知っています。私が添付しようとしているデータは、実行時に収集されNSDictionaryに格納されNSDataにシリアル化された情報ですが、メールが送信されるたびに添付ファイルの兆候はありません。私のコードは、受信者の電子メール、本文、件名がすでに入力されているMFMailComposeViewControllerビューを最初に表示します。次に、匿名データを収集できるかどうかを尋ねるアラートボックスを表示します。 [はい]をクリックすると、アラートビューのコールバックメソッドがデータをコンパイルし、MFMailComposeViewControllerにアタッチします。デバッガでデータをステップ実行すると、すべてのデータが正しく表示されますが、添付されたデータは電子メールと一緒に届くことはありません。ここに私のコードは...iOS開発:私のplistデータをMFMailComposeViewControllerに添付できないのはなぜですか?
-(void)displayComposerSheet
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Temp Subject Line"];
NSArray *toRecipients = [NSArray arrayWithObjects:@"[email protected]", nil];
[picker setToRecipients:toRecipients];
NSString *emailBody = @"Temporary email body";
[picker setMessageBody:emailBody isHTML:NO];
[self setMailViewController:picker];
[self presentModalViewController:picker animated:YES];
UIAlertView* uiav= [[UIAlertView alloc] initWithTitle: @"May we collect data from you?"
message: @"May we collect some data form you?"
delegate: self cancelButtonTitle: @"No" otherButtonTitles: nil];
[uiav addButtonWithTitle:@"Yes"];
[uiav setDelegate:self];
[uiav show];
[uiav release];
[picker release];
}
- (void) alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 1)
{
NSMutableDictionary *appData = [[[NSMutableDictionary alloc] init] autorelease];
.
. //Compile the application data to attach to email
.
NSString *errorString = [[[NSString alloc] init] autorelease];
NSData *attachData = [NSPropertyListSerialization dataFromPropertyList:appData format:NSPropertyListXMLFormat_v1_0 errorDescription:&errorString];
[[self mailViewController] addAttachmentData:attachData mimeType:@"text/xml" fileName:@"app data"];
}
}
}
アイデア?それは私がMFMailComposeViewControllerをロードした後にデータを添付しようとしているという事実と関係がありますか?
あなたの知恵に感謝します。
ahh miss it!ありがとうございました! – BeachRunnerFred