デバイスを回転させたときにビューのレイアウトを変更しようとして問題が発生しました。メインビューはOverviewViewControllerと呼ばれ、デバイスが特定の方向にあるときに非表示/表示される2つのビューで構成されています。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// do some layout stuff
NSLog(@"OverviewViewController shouldAutorotateToInterfaceOrientation");
return YES;
}
デバイスを回転させるたびに、このメソッドは2回実行されますが、たとえば、どのサブビューでも呼び出されることはありません。
// In OverviewViewController
_landscapeView = [[LandscapeOverviewViewController alloc] initWithNibName:nil bundle:nil];
[self.view addSubview:_landscapeView.view];
// In LandscapeOverviewViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
NSLog(@"LandscapeOverviewViewController: shouldAutorateToInterfaceOrientation");
// Only change orientation when it's landscape
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) return YES;
return NO;
}
サブビューがデバイスの向きに応答しない理由はありますか?メソッドがそこで呼び出されることはありません。