0

アプリデリゲートにメールコンポーザーを実装しています。理由はわかりませんが、警告が表示されます

「インスタンス メソッド presentModalViewController:animated が見つかりません」

appdelegate でのみですが、他のビューコントローラーでも同じ方法を使用していますが、これはスムーズに機能します。

  MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init]; 
  mail.mailComposeDelegate = self; 

  if([MFMailComposeViewController canSendMail]) 
  {
     //Setting up the Subject, recipients, and message body.

     [mail setToRecipients:[NSArray arrayWithObjects:@"abc@gmail.com",nil]];
     UIImage *pic = [UIImage imageNamed:@"page0.png"];
     NSData *exportData = UIImageJPEGRepresentation(pic ,1.0);
     [mail addAttachmentData:exportData mimeType:@"image/jpeg" fileName:@"Picture.jpeg"];

     [mail setSubject:@"dummy text"];
     [mail setMessageBody:@"Please tell us what your concerns are and we will try to fix them" isHTML:NO];
     //Present the mail view controller
     [self presentModalViewController:mail animated:YES]; 
     //release the mail [mail release];
  } 

[self presentModalViewController:mailer animated:YES];これは警告を発しており、ここに到達するとアプリがクラッシュします。

助言がありますか。

4

6 に答える 6

3
[self presentModalViewController:mail animated:YES];   

UIViewControllers メソッドです。UIViewController からクラスを拡張したかどうかを確認してください

@interface abc : UIViewController
于 2012-12-26T04:27:07.927 に答える
0

presentModalViewController:animated:that's methodのために動作しませんUIViewControllerが、selfここにありapp delegateます。

詳細については、 ViewControllersのリンクを参照してください

于 2012-12-26T04:42:16.647 に答える
0

アプリのデリゲートでこれを実装する理由。別のビューを作成し、AppDelegate がビューで行っていることをすべて配置してから、このコードをビューコントローラーに実装します。AppDelegate では、PresentModalViewController のようなコードを実装しようとすることはできません。新しいビューを作成し、起動時にそのビューをロードするようにアプリ デリゲートを指定するだけです。

于 2012-12-26T04:21:49.723 に答える
0

presentModalViewController はUIViewControllerのサブクラスのメソッドであり、 のメソッドでappDelegateはありません。これは、それ自体のビュー コントローラーを持たないためです。

できることは、それを使用している場合は、ナビゲーションコントローラーの最後のビューコントローラーに提示することです

于 2012-12-26T04:19:55.377 に答える