邮件撰写视图控制器无法从 UIAlertController 打开
Mail Compose View Controller Won't Open From UIAlertController
我试图在从 UIAlertController 按下按钮后启动邮件撰写视图控制器。在模拟器中,当我尝试打开邮件时,我总是在模拟器中收到正常的崩溃和错误消息,但在应用程序中,我什么也得不到。没有控制器,没有崩溃,什么都没有。这是代码。
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Email" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self emailThem];
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
-(void) emailThem {
NSLog(@"EMAIL");
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;
[mail setSubject:@"To P3 Media"];
[mail setMessageBody:@"Replace this text with your message for all the information you would like on P3 Media." isHTML:NO];
[mail setToRecipients:@[@"p3media2014@gmail.com"]];
[self presentViewController:mail animated:YES completion:NULL];
}
有什么问题?
试试这个代码
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Email" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self emailThem];
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
-(void) emailThem {
NSLog(@"EMAIL");
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;
[mail setSubject:@"To P3 Media"];
[mail setMessageBody:@"Replace this text with your message for all the information you would like on P3 Media." isHTML:NO];
[mail setToRecipients:@[@"p3media2014@gmail.com"]];
dispatch_async(dispatch_get_main_queue(),^{
[self presentViewController:mail animated:YES completion:NULL];
});
}
我试图在从 UIAlertController 按下按钮后启动邮件撰写视图控制器。在模拟器中,当我尝试打开邮件时,我总是在模拟器中收到正常的崩溃和错误消息,但在应用程序中,我什么也得不到。没有控制器,没有崩溃,什么都没有。这是代码。
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Email" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self emailThem];
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
-(void) emailThem {
NSLog(@"EMAIL");
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;
[mail setSubject:@"To P3 Media"];
[mail setMessageBody:@"Replace this text with your message for all the information you would like on P3 Media." isHTML:NO];
[mail setToRecipients:@[@"p3media2014@gmail.com"]];
[self presentViewController:mail animated:YES completion:NULL];
}
有什么问题?
试试这个代码
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Email" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self emailThem];
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
-(void) emailThem {
NSLog(@"EMAIL");
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;
[mail setSubject:@"To P3 Media"];
[mail setMessageBody:@"Replace this text with your message for all the information you would like on P3 Media." isHTML:NO];
[mail setToRecipients:@[@"p3media2014@gmail.com"]];
dispatch_async(dispatch_get_main_queue(),^{
[self presentViewController:mail animated:YES completion:NULL];
});
}