0

横向きに回転すると新しいビューがスタックにプッシュされ、縦向きに戻るとそのビューがポップされるナビゲーションコントローラーを作成しようとしています。これまでのところ、横向きのビューを表示できますが、そのビュー コントローラーをスタックに再度プッシュすることで縦向きに戻すことができる場合のみです。ユーザーが連続して前後に回転すると、スタックがメモリ不足になると思います。popToViewController を使用しようとしても、何も起こりません。誰かがポップ機能を機能させるのを手伝ってくれますか?

このメソッドは、ViewController クラスにあります。

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
       toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        AppDelegate *delegate =
        (AppDelegate *)[[UIApplication sharedApplication] delegate];

        Landscape *landScape=
        [[Landscape alloc] initWithNibName:@"Landscape" bundle:nil];

        [delegate.navController pushViewController:landScape animated:YES];
    }
}

このメソッドは、Landscape クラスにあります。

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if(toInterfaceOrientation == UIInterfaceOrientationPortrait ||
            toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        AppDelegate *delegate =
        (AppDelegate *)[[UIApplication sharedApplication] delegate];

        ViewController *viewController=
        [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];

        [delegate.navController pushViewController:viewController animated:YES];
    }
}
4

1 に答える 1

1

あなたのViewControllerはすでにスタック上にあるはずなので、[delegate.navController popViewControllerAnimated:YES];代わりに呼び出すことでそれを取り戻すことができるはずです[delegate.navController pushViewController:viewController animated:YES];

于 2012-08-07T00:13:44.827 に答える