How to create multiple Views for the same Window in Cocoa?
I have application that has one Application delegate, and one Window. I have different classes that running threads, etc. When I'm sending NSWindow *window pointer to that classes or function, and trying to change VIew , [window setcontentView//something]. It doesn't display anything ,what I am doing wrong ? What is the easiest way to 开发者_运维百科have one window, and different classes, and change that Content for that window, from different classes. Thanks.
At first you should implement your UIApplicationDelegate method didFinishLaunchingWithOptions something like this:
MainViewController *mainController = [[[MainViewController alloc] initWithNibName:@"MainView" bundle:nil] autorelease];
navigationController = [[UINavigationController alloc] initWithRootViewController:mainController];
navigationController.navigationBar.hidden = YES;
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
Later you can create different UIViewController instances and push them to UINavigationController object.
精彩评论