开发者

Changing the ViewController in NIB

I created a VIEW based application named ktemp1. and It generated .., ktempView1Controller.h and ktempView1Controller.m..,

Later I created one more view.., say "ktemp2ViewController.h" and "ktemp2ViewController.m".

I have a navigationController defined in AppDeligate with rootViewController set as ktempView1ViewController., Having done this All Works fine..

BUT, What I want is to set ktemp2ViewController as the rootViewController.

To do this, I am changing the ViewController class in MainWindow.Xib to ktemp2ViewController and changing the rootViewController to ktemp2ViewController.., But whenever I run the app开发者_如何学Golication, I am getting ktempView1 as the rootView and even when I click on the ktemp2ViewController in MainWindow.Xib , the view in IB is getting loaded from ktemp1ViewController... Can anyone guide me ?


In the standard apple template, you will find something like this in your AppDelegate didFinishLaunching.

window.rootViewControlller = self.viewController;

There should be only a single rootViewController in your application and you should not attempt to set it frm anywhere else than the AppDelegate.

So what is relevant in your case, is the viewController property of the appDelegate. When you look at your MainWindow.xib, you need to make sure it contains a kTempViewController2 and that is wired to your AppDelegate.viewController property (the AppDelegateshould be the MainWindow.xib owner).


I hope you have Navigation controller in your mainWindow.xib.

Explore it and you could see a view controller (root view controller) and other view controller, if any.

Select the root view controller, set its class type and specify its nib name.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜