I have created a baseview project in xcode4. I want to use a new xib file to instead of the old viewController.xib file. So I just change the old viewController.xib file’s name. and I also change the MainWindows.xib, let the UIViewController direct to the new name one xib file.
All are ok, but the view are transparent in the MainWindows, like link the xib to UIViewController are not correct. I don’t know..
My step are:
1. create a new xib file.
2. link the new xib file to MyUIViewController class
![I think link way is this,I don’t know if is correct?]
Try other way:
If I use the xcode template to add sub UIViewController (include xib and class file), and add the code like:
testViewControllerViewController *Controller = [[testViewControllerViewController alloc] init];
self.viewController = Controller;
[Controller release];
//self.window.rootViewController = self.viewController;
[self.window addSubview:self.viewController.view];
[self.window makeKeyAndVisible];
The xib content are show correct.
If I change the name of xib file, the xib content are not show. Because I want to create the Class first, and use the old xib file.
Any body know how to resolve it: Create xib file and sub UIViewController separately.
If these are way to do this, There is a problem: I have two xib file and link to only one UIViewController, if I use the UIViewController, which xib is used?
So, I want to sure whether can we create the xib file and sub UIViewController separately?
Why we must set the Custom Class file to SUB UIViewController, show as the picture above.
I’m not sure if I understand the problem correctly, but are you asking why you must always add the Controller’s view as a subview to the main window?
The iPhone hierarchy is quite simple: every App has a main window, with a controller. This controller has a View, most of the time.
So, to make your app do something, and show something you will need to add the Controlling logic (from the Controller) and the View that it’s controlling to the main window, by calling