RootViewControllerによって制御される複数のUIViewControllerでアプリケーションを構築しています。現在、plistではデフォルトでLandscapeRightに設定されています。iPhone:ランドスケープと肖像画のみを表示するアプリ
は私がRootViewControllerにロードすることができ、次のファイルを持っているとしましょう:
- IntroView(ONLY風景右)
- LandscapeView(ONLY風景右)
- PortraitView(ONLYポートレート)
また、RootViewControllerのshouldAutorotateToInterfaceOrientationに次のものを追加しました:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if ([currentClass class] == PortraitView.class) {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
} else {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
}
私はPortraitViewにロードし、viewWillAppearで私はこれが適切に今PortraitViewにロードされたが、私の問題をもたらしthis thread
if (self.interfaceOrientation == UIInterfaceOrientationPortrait) { //UIInterfaceOrientationLandscapeRight) {
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
self.view.bounds = CGRectMake(0.0, 0.0, 320, 480);
self.view.center = CGPointMake(240.0f, 160.0f);
}
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
に似た(以下を追加するまで、そのすべてが順調ですそれは私のPortraitView内に私は2つのサブビューを持っていますが、私は私のビューを回転させたのでUIViewAnimationTransitionFlipFromLeftは実際には左から右への代わりに下から上にフリップします。私は私の人生のために、PortraitViewにポートレートを伝える方法を理解できません。
[[UIDevice currentDevice] orientation]をチェックすると、それは風景の中で私に伝えます。 shouldAutorotateToInterfaceOrientationを使用してポートレートのみに設定しようとすると、ビューが回転してもはや正しくないようになります。
これはうまくいけばうまくいきます。一日中この問題を見てきました。
ありがとうございます!
RootViewControllerのスーパークラスとは何ですか?それは単純なUIViewControllerですか? –
はい、ただUIViewControllerです。私はナビゲーションやタブバーを使用していません。 –