Just want to add a subview into navigationbar, but always failed.Finally I have found the reason, but I don't know why. app
In the AppDelegate.m's this
- (BOOL)application:didFinishLaunchingWithOptions:
I have added a mainviewcontroller as instance. spa
NavController *navigationController = [[NavController alloc] init]; MainViewController *controller = [[MainViewController alloc] init]; NSLog(@"frame: %@", NSStringFromCGRect([controller view].frame)); // ??? // **** set root view controller [navigationController initWithRootViewController:controller]; // NSLog(@"frame: %@", NSStringFromCGRect([controller view].frame)); // ??? [controller release]; [self.window addSubview:navigationController.view]; [self.window makeKeyAndVisible];
NSLog(@"frame: %@", NSStringFromCGRect([controller view].frame)); // ???if I added it below the controller init method, the subview in mainviewcontroller's navigationbar will not be added, but if I added the code below the initRootViewController method, the subview can be aded.
How is it? I really don't know why. code
Thanks, it
Blues io