我正在为 iOS 7 开发一个应用程序并使用MFMailComposerViewController
.
我已经尝试了一切,但dismissViewController:withAnimated
没有工作。
viewController
有时类在第一次使用方法显示时会自动调用委托presentViewCOntroller:withAnimated:completion
。
我的应用程序是基于导航的,这就是为什么我认为问题也与之相关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:@"first@example.com"];
NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil];
NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"];
[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 *lastTable=@"</table>";
[emailBody appendString:lastTable];
NSLog(@"%@",emailBody);
[picker setMessageBody:emailBody isHTML:YES];
[self presentViewController:picker animated:YES completion:NULL];
}