开发者

How to create multiple Views for the same Window in Cocoa?

开发者 https://www.devze.com 2023-04-04 01:05 出处:网络
I have application that has one Application delegate, and one Window. I have different classes that running threads, etc. When I\'m sendingNSWindow *window pointer to that classes or function, and try

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号