2011-08-15 19 views
1

誰かがUIImagePickerControllerで写真を選択した直後に電子メールのダイアログを表示しようとしています。その後すぐにポップアップすることはできません。私は何か間違っているのですか?最終的に私は写真を添付ファイルにしますが、それは難しい部分ではありません。電子メールと写真の両方のモーダルを個別に表示することができます。ありがとう!UIImagePickerControllerの直後にMFMailComposeViewControllerを呼び出す

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
// Hide the dialouge 
[picker dismissModalViewControllerAnimated:YES]; 
[self becomeFirstResponder]; 

MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init]; 
controller.mailComposeDelegate = self; 
[controller setSubject:@"test"]; 
[controller setMessageBody:@"test" isHTML:NO]; 

[self presentModalViewController:controller animated:YES]; 

}

答えて

1

あなたのイメージピッカーを隠すためにアニメーションを使用しているため。

UIImagePickerControllerは、MFMailComposeViewControllerを表示しようとしているときに実際には解除されません。そのため、エラーが発生します。

あなたはこの問題を回避するために

[picker dismissModalViewControllerAnimated:NO]; // (set Animated to "NO") 

にあなたのコード

[picker dismissModalViewControllerAnimated:YES]; 

を変更することができます。

P.S.なぜあなたが追加しているのかよく分かりません

[self becomeFirstResponder]; 

そこには必要ないようです。

+0

あなたはチャンピオンです。とてもシンプルなもの。ありがとうございました – user634944

関連する問題