アプリの UILabel を作成するための簡単なコードは次のとおりです。
UILabel *todaysGame = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 300, 250)];
todaysGame.text = @"Today's Game";
todaysGame.backgroundColor = [UIColor grayColor];
[self.view addSubview:todaysGame];
これは私の iPhone 5 の画面の高さにぴったりですが、iPhone 4 の画面では台無しになりました。iOS 6 の自動レイアウト機能を読んでみましたが、やり方がよくわかりませんでした。ストーリーボードや NIB を使用したくありません。プログラムで実行したいと考えています。iPhone 4 および 5 の画面の高さと互換性のある UI 要素を配置する方法。
また、数字を使用する代わりにこれが役立つかどうかも確認しようとしました
screenBound = [[UIScreen mainScreen] bounds];
screenSize = screenBound.size;
screenWidth = screenSize.width;
screenHeight = screenSize.height;
「screenHeight」変数を CGRectMake() メソッドに使用しました。
Xcode 4.6 と iPhone 5 (iOS 6.1.3) と iPhone 4 を同じものに使用しています。