横向きに回転すると新しいビューがスタックにプッシュされ、縦向きに戻るとそのビューがポップされるナビゲーションコントローラーを作成しようとしています。これまでのところ、横向きのビューを表示できますが、そのビュー コントローラーをスタックに再度プッシュすることで縦向きに戻すことができる場合のみです。ユーザーが連続して前後に回転すると、スタックがメモリ不足になると思います。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];
}
}