I've just started to make a new app with a navigation bar. I made the first view with the navigation in the 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;
}
Then, I making the view of the HomeViewController inside loadView
method.
LoadView of HomeViewController :
- (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];
}
My label Hello World doesn't appear...
For the frame, if I set CGRectMake(0, 65, 50, 20)
, 65
for y
, my "Hello World" appears... (I know, I have to increase the width :) )
I just don't understand the origins of my view... If someone can explain me please.
Thanks