私はiPadプロジェクトを次のように構成しています:-AppDelegate-MainWindow-ViewController-View
View Controllers .mファイルは、プログラムで別のビューをロードし、それを画面に配置します。このビューはスライドインおよびスライドアウトされます。
私はこれをします:
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect viewRect = CGRectMake(0, 0, 0, 0);
CalculatorView *v = [[[CalculatorView alloc]
initWithFrame:viewRect] autorelease];
[self.view.window addSubview:v];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
v.view.frame = CGRectMake(0, 0, 460, 320);
[UIView commitAnimations];
}
私が抱えている問題は、ここで追加しているサブビューの方向が正しくないように見えることです。プロジェクトはランドスケープのみをサポートし、ランドスケープを起動します。コンテナビューは問題なく、ボタンもいくつか含まれています。ただし、このプログラムでロードされたビューはポートレートモードでスタックします。次の自動回転コードを提供しました(ロードされたビューの.m内):
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
しかし、それは決して呼び出されません。
では、プログラムで追加されたサブビューをポートレートモードではなくランドスケープモードでロードするにはどうすればよいですか?TIA!