尝试将邮件集成到我的应用程序中,收到 2 条警告

发布于 2024-09-30 02:16:56 字数 1458 浏览 11 评论 0原文

我正在尝试将发送邮件集成到我的应用程序中,但最终收到两个警告。我正在使用 Obj-C,即 Cocos2d 框架。这是我的代码。

    -(void) mailTapped: (id) sender {
 MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
 composer.mailComposeDelegate = self;
 if ([MFMailComposeViewController canSendMail]) {
  [composer setToRecipients:[NSArray arrayWithObjects:@"", nil]];
  [composer setSubject:@"Check Out This Awesome App!"];
  [composer setMessageBody:@"I found this great game on the App Store! It's called Mole Attack. It's a side scroller with an epic story. You can check out some screenshots of the gameplay and download it here. Download link - " isHTML:NO]; //Include link and pics
  [self presentModalViewController:composer animated:YES];  // <--- warning - GameOver (name of class) may not respond to '-presentModalViewController:animated:'
 }
} 

-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
 [self dismissModalViewControllerAnimated:YES]; // <--- warning - GameOver may not respond to '-dismissModalViewControllerAnimated:YES'
 if (result == MFMailComposeResultFailed) {
  UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failed" message:@"The email was not sent. You must be in wifi or 3G range. Try again later." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
  [alert show];
  [alert release];
 }
}

提前致谢!

I'm trying to integrate sending mail into my app, but I end up with 2 warnings. I am using Obj-C, the Cocos2d Framework. This is my code.

    -(void) mailTapped: (id) sender {
 MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
 composer.mailComposeDelegate = self;
 if ([MFMailComposeViewController canSendMail]) {
  [composer setToRecipients:[NSArray arrayWithObjects:@"", nil]];
  [composer setSubject:@"Check Out This Awesome App!"];
  [composer setMessageBody:@"I found this great game on the App Store! It's called Mole Attack. It's a side scroller with an epic story. You can check out some screenshots of the gameplay and download it here. Download link - " isHTML:NO]; //Include link and pics
  [self presentModalViewController:composer animated:YES];  // <--- warning - GameOver (name of class) may not respond to '-presentModalViewController:animated:'
 }
} 

-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
 [self dismissModalViewControllerAnimated:YES]; // <--- warning - GameOver may not respond to '-dismissModalViewControllerAnimated:YES'
 if (result == MFMailComposeResultFailed) {
  UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failed" message:@"The email was not sent. You must be in wifi or 3G range. Try again later." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
  [alert show];
  [alert release];
 }
}

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牵你手 2024-10-07 02:16:56

您确定您的 GameOver 类继承自 UIViewController 吗?该类定义了您收到警告的两种方法。

Are you sure your GameOver class is inheriting from UIViewController? That's the class that defines the two methods that you're getting warnings about.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文