1 用自带的邮件客户端,发完邮件后不会自动回到原应用 2 NSURL *url = [NSURL URLWithString:@"mailto://[email protected]"]; 3 [[UIApplication sharedApplication] openURL:url];
1 跟发短信的第2种方法差不多,只不过控制器类名叫做:MFMailComposeViewController 2 3 邮件发送后的代理方法回调,发完后会自动回到原应用 4 - (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error 5 { 6 // 关闭邮件界面 7 [controller dismissViewControllerAnimated:YES completion:nil]; 8 9 if (result == MFMailComposeResultCancelled) { 10 NSLog(@"取消发送"); 11 } else if (result == MFMailComposeResultSent) { 12 NSLog(@"已经发出"); 13 } else { 14 NSLog(@"发送失败"); 15 } 16 }
时间: 2024-11-05 16:38:21