部分的なカール遷移を使用して、マップの下にオプション パネルを表示するマップ ベースのアプリから、モーダル ビュー コントローラーを正常に実装しました。
ここから、ユーザーが MFMailComposeViewControl を使用してメールで連絡できるボタンを実装したいと思います。以下のコードを実装しましたが、ボタンをタップするたびにアプリケーションがクラッシュし、presentModalView が呼び出されます。
この問題は、モーダル ビューを別のビューの上に呼び出そうとすることに関連しているに違いないことはわかっていますが、解決方法がわかりません。
クラッシュメッセージは次のとおりです。
* -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:]、/SourceCache/UIKit_Sim/UIKit-1914.84/UIWindowController.m:188 でのアサーションの失敗
- (IBAction)sendSupportMail:(id)sender{
// log this in the debugger
NSLog(@"You hit the send support mail button.");
// dismiss the page curled options view
[self dismissModalViewControllerAnimated:YES];
// check to see if email is available; if so, compose message
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@"Subject here"];
NSArray *toRecipients = [NSArray arrayWithObjects:@"first@mail.com", @"second@mail.com", nil];
[mailer setToRecipients:toRecipients];
NSString *emailBody = @"Body Copy";
[mailer setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:mailer animated:YES];
NSLog(@"Present Mailer Called");
[mailer release];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
message:@"Your device doesn't support the composer sheet"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];
[alert release];
}
}