私はiPadアプリケーションを持っています。横向きUIViewControllerのビューの実際の幅 =1024pxおよび高さ = 768 - 20 (statusBar) - 44 (navigationBar) = 704px.
なので、この[1024 x 704]サイズが欲しくて使っself.view.boundsています。が返されますが[748 x 1024]、これは間違っています! しかし、画面を 2 回回転すると (現在 -> 縦 -> 現在)、ビューの境界は正しい[1024 x 704]です。
ビューは次のように初期化されました。
- (void)loadView {
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view.backgroundColor = [UIColor lightGrayColor];
}
そして境界は次のようになりました:
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"bounds = %@", NSStringFromCGRect(self.view.bounds));
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
NSLog(@"bounds = %@", NSStringFromCGRect(self.view.bounds));
}
問題は..最初に正しいビューの境界を取得するにはどうすればよいですか?