0

複数のビューを持つナビゲーション ベースのアプリケーションを取得しました。最後のビューに到達すると、アプリケーションはメールを送信します (MailComposer を使用)。その後、ホーム ビューに戻りたいと思います。

すべて正常に動作しますが、次を使用してホーム vie に戻ろうとすると: [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];
}
}
4

6 に答える 6

0

[self.navigationController popToRootViewControllerAnimated:NO];

于 2011-08-09T11:10:20.060 に答える
0

iOS4 (iOS5 ではない) の UIAlertView コールバック内で呼び出されることに問題がpopToRootViewController:animated:あったため、代わりに、シングルトン クラスによって受信されたコールバック内に通知を投稿し、シングルトンが呼び出されました。popToRootViewController:animated:

于 2012-06-03T16:02:30.423 に答える
0

以前のViewControllers(特に、最後のviewControllerに移動するViewController)にリリースまたは自動解放があるかどうかを確認してください。

[self.navigationController pushViewController:yourViewController animated:YES];

次のようなものがあるかもしれません:

vController = [[YourViewController alloc] initWithNibName:@"HighScoreViewController" bundle:nil] autorelease];

そのため、autorelease を削除する必要があります

于 2013-12-18T09:33:32.143 に答える
0

以下に示すコード行をコメントアウトします。

//  [self dismissModalViewControllerAnimated:YES];
于 2011-08-09T11:16:39.883 に答える
-1

[self popToRootViewControllerAnimated:NO]; を試してください。

于 2011-08-09T11:04:29.470 に答える