ストーリーボードを使用して iPad ランドスケープ アプリを開発しています。私は同じために以下の手順を実行しました。私のアプリは、シミュレーターのランドスケープで画面が開いています..しかし、間違ったフレームを取得しています。
- ストーリーボード用の xcode からのサンプル アプリ テンプレート。
- info-plist ファイルからの横方向のみを許可する
- ストーリーボード -> UIViewController -> シミュレートされた行列 -> 向きを横向きに変更
以下のメソッドを view controller.m に実装
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)); }
フレームと境界の NSLog を取得すると、縦長のフレームが表示されます。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"bounds ::%@",NSStringFromCGRect(self.view.bounds));
NSLog(@"frame ::%@",NSStringFromCGRect(self.view.frame));
}
結果ログ:
bounds ::{{0, 0}, {748, 1024}}
frame ::{{20, 0}, {748, 1024}}
何か不足していますか?