我正在開發iOS 7的應用程序,並使用MFMailComposerViewController
。如何在iOS 7上使用MFMailComposerViewController?
我已經嘗試了一切,但dismissViewController:withAnimated
不起作用。
有時會在第一次使用方法presentViewCOntroller:withAnimated:completion
顯示viewController
時自動調用委託。
我的應用程序基於導航,這就是爲什麼我認爲問題也與UINavigationController
有關。
-(void)sendMail{
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Hello from California!"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"];
NSArray *ccRecipients = [NSArray arrayWithObjects:@"[email protected]", @"[email protected]", nil];
NSArray *bccRecipients = [NSArray arrayWithObject:@"[email protected]"];
[picker setToRecipients:toRecipients];
[picker setCcRecipients:ccRecipients];
[picker setBccRecipients:bccRecipients];
// Fill out the email body text
NSMutableString *emailBody =[NSMutableString stringWithString: @"<table border=1 align=\"center\"><tr><th>EventDate</th><th>EventDay</th><th>EventTime</th><th>Speaker</th><th>topic</th></tr>"];
for (int i=0; i<5; i++) {
NSString *eventDate=[NSString stringWithFormat:@"<tr><td>%@</td>",@"12/11"];
NSString *eventDay=[NSString stringWithFormat:@"<td>%@</td>",@"Sunday"];
NSString *eventTime=[NSString stringWithFormat:@"<td>%@</td>",@"12:10 pm"];
NSString *eventSpeaker=[NSString stringWithFormat:@"<td>%@</td>",@"RajVeer"];
NSString *eventTopic=[NSString stringWithFormat:@"<td>%@</td>",@"nano-technology"];
NSString *dataString=[NSString stringWithFormat:@"%@%@%@%@%@</tr>",eventDate,eventDay,eventTime,eventSpeaker,eventTopic];
[emailBody appendString:dataString];
}
NSString *[email protected]"</table>";
[emailBody appendString:lastTable];
NSLog(@"%@",emailBody);
[picker setMessageBody:emailBody isHTML:YES];
[self presentViewController:picker animated:YES completion:NULL];
}
向我們展示你正在使用呈現和罷免視圖控制器的代碼。 –
在iOS 7上,它的工作方式是在早期版本的iOS上運行(剛測試過)。它應該是你的代碼有問題。 –