0

このコードを使用したとき:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:    (NSTimeInterval)duration {

  if ((toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft) || toInterfaceOrientation==UIInterfaceOrientationLandscapeRight ) {
    LeftLVC* vc = [[LeftLVC alloc] initWithNibName:@"LeftLVC" bundle:nil];      
    [self.navigationController pushViewController:vc animated:YES];     
  }
}

サブビューが回転します。私のプロジェクトでは、サブビューは固定された縦向きのままでなければなりません。

4

1 に答える 1

0

shouldAutorotateToInterfaceOrientation:サポートされる方向を指定するために使用されます。ポートレート モードのみをサポートする場合は、次のようにします。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
        return UIInterfaceOrientationIsPortrait(interfaceOrientation);  
}

上記の方法は、iOS 6.0 では非推奨です。supportedInterfaceOrientations代わりにandpreferredInterfaceOrientationForPresentationメソッドをオーバーライドします。詳細については、Apple のドキュメントを参照してください。

willRotateToInterfaceOrientation:duration:ユーザー インターフェイスが回転を開始する直前にビュー コントローラーに送信されます。ここで、このメソッドは、方向を横から縦に移動するときに呼び出されます。

于 2012-10-08T11:19:21.420 に答える