我得到了具有多个视图的基于导航的应用程序。当我到达最后一个视图时,应用程序将发送一封电子邮件(使用 MailComposer)。之后就想回到家中查看。
一切正常,但是当我尝试使用以下方法返回主页时: [self.navigationController popToRootViewControllerAnimated:YES]; 应用程序将崩溃并显示“EXC_BAD_ACCESS”错误。我知道我可以使用 NSZombie 进行调试,但是当我尝试在 NSZombie 中获取错误时,不会出现错误。
我怎样才能解决这个问题?或者有没有办法只释放所有视图并重新加载第一个视图?任何提示或任何可以帮助我的东西都会很棒。这是一些代码:
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
// Notifies users about errors associated with the interface
switch (result)
{
UIAlertView *alert;
case MFMailComposeResultCancelled:
NSLog(@"melding cancelled");
alert = [[UIAlertView alloc]initWithTitle:@"Email afgebroken" message:nil delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
break;
case MFMailComposeResultSaved:
NSLog(@"melding opgeslagen");
alert = [[UIAlertView alloc]initWithTitle:@"Email opgeslagen" message:nil delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
break;
case MFMailComposeResultSent:
NSLog(@"melding verzonden");
alert = [[UIAlertView alloc]initWithTitle:@"Email verzonden" message:nil delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
[self saveMelding];
break;
case MFMailComposeResultFailed:
NSLog(@"melding failed");
alert = [[UIAlertView alloc]initWithTitle:@"Email mislukt te versturen" message:@"probeer het later nog eens" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
break;
default:
NSLog(@"melding niet verzonden");
alert = [[UIAlertView alloc]initWithTitle:@"Email niet verzonden" message:nil delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
break;
}
[self dismissModalViewControllerAnimated:YES];
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0)
{
NSLog(@"ok");
[self.navigationController popToRootViewControllerAnimated:YES];
}
}