我已经从基于地图的应用程序中成功实现了一个模态视图控制器,它使用部分卷曲过渡在地图下方显示了一个选项面板。
从这里,我想实现一个按钮,允许用户使用 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];
}
}