전자 메일을 통해 아래 코드를 사용하여 장치 로그 파일을 보내려고합니다. iPod touch 및 iPad에서 이메일을 Wi-Fi 네트워크로 보낼 수 있습니다. 그러나 3G 네트워크에서 iPhone으로 이메일을 보내려고 할 때 충돌이 발생합니다. 나는 코드를 데뷔하고 presentModalViewController를 수행하는 동안 이것이 충돌하고 있음을 알게되었다.3G에서 이메일을 보내는 동안 현재의 모니터 뷰 컨트롤러가 충돌 함
이 문제를 해결하는 방법을 알려주십시오.
- (IBAction)sendEmail:(id)sender
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
// Set the subject of email
[picker setSubject:@"Debug Log"];
// Add email addresses
[picker setToRecipients:[NSArray arrayWithObjects:@"[email protected]", @"[email protected]", nil]];
// Fill out the email body text
NSString *emailBody = @"Debug Log content…… ";
// This is not an HTML formatted email
[picker setMessageBody:emailBody isHTML:NO];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *logPath = [documentsDirectory
stringByAppendingPathComponent:@"console.log"];
NSData *data = [NSData dataWithContentsOfFile:logPath];
[picker addAttachmentData:data mimeType:@"text/xml" fileName:@"console.log"];
// Show email view
[self presentModalViewController:picker animated:YES];//app crash
// Release picker
[picker release];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
// Called once the email is sent
// Remove the email view controller
[self dismissModalViewControllerAnimated:YES];
}