ナビゲーションバーを備えた新しいアプリの作成を始めたばかりです。のナビゲーションで最初のビューを作成しましたAppDelegate.m
。
AppDelegate.m :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
sleep(2);
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:[[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil]];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}
次に、メソッド内の HomeViewController のビューを作成しますloadView
。
HomeViewController の LoadView :
- (void)loadView
{
self.view = [[UIView alloc] init];
self.view.backgroundColor = [UIColor whiteColor];
self.searchPoiInstructionsLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 20)];
self.searchPoiInstructionsLabel.layer.borderColor = [UIColor blackColor].CGColor;
self.searchPoiInstructionsLabel.layer.borderWidth = 2.0f;
self.searchPoiInstructionsLabel.text = @"HELLO WORLD";
[self.view addSubview:self.searchPoiInstructionsLabel];
}
ラベル Hello World が表示されない...
フレームにCGRectMake(0, 65, 50, 20)
、65
forを設定するy
と、「Hello World」が表示されます...(わかっています、幅を増やさなければなりません:))
私は自分の見解の起源を理解していません.誰かが私を説明できるなら.
ありがとう