我是 xcode 的新手,想知道如何在应用程序中发送电子邮件!我的代码在下面,但我不断收到错误消息“'jakem' 没有可见的@interface 声明选择器'presentViewControllerAnimated:'”。我的代码完全错误吗?还是我只是忘记声明选择器,如何声明选择器?我已经在互联网上研究了至少一个小时,但没有任何效果。有人请帮助我!
-(IBAction)sendEmail{
MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
[composer setMailComposeDelegate:self];
if ([MFMailComposeViewController canSendMail]) {
[composer setToRecipients:[NSArray arrayWithObjects:@"FrankMurphy.CEO@RomansXIII.com", nil]];
[composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentViewController:composer animated:YES];
}
}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
if(error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"error" message:[NSString stringWithFormat:@"error %@", [error description]] delegate:nil cancelButtonTitle:@"dismiss" otherButtonTitles:nil, nil];
[alert show];
[self dismissViewControllerAnimated:YES];
}
else {
[self dismissViewControllerAnimated:YES];
}
}