私はそれにUIViewController UIWebViewを持っています。私はUIWebViewを風景やポートレートモードでiPad画面の中央に配置したいと思います。だから、私はこのように実装しましたなぜ私のビューは正しくinterfaceOrientationの位置に配置されていませんか?
// UIViewController
// InfoGraphicView is the UIWebView
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait ||
toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
[self layoutPortrait];
} else {
[self layoutLandscape];
}
}
- (void)layoutLandscape {
NSLog(@"Layout Landscape");
infoGraphicView.frame = CGRectMake(100, 100, 936, 700);
}
- (void)layoutPortrait {
NSLog(@"Layout Portrait");
infoGraphicView.frame = CGRectMake(100, 100, 700, 936);
}
しかし、期待通りに動作していません。上のコードでは、UIWebViewが左上から100px(または何かの単位でも)離れることを期待しています。しかし、そうではありません。ポートレートモードでは画面の左上に表示され、横モードでは左上で部分的にオフスクリーンに見えます。
フレームをCGRectMake(-100, 100, 700, 936)
と設定すると、画面の中央に配置されますが、その理由はわかりません。
いつものように、私は見落としている可能性が最も高いですが、私はそれを理解できません。どんな助けもいつものように大きく評価されました