Search code examples
uitableviewviewxcode4uiviewcontrollermainwindow

Xcode 4: Switch Views to MainWindow.xib


I'm pretty new to Objective-C and Xcode, so it would be really helpful if you could give a detailed answer. I'm working with a Navigation-Based Application and I have a menu. If the user clicks on a specific button, the tableview and the navigation bar should load up. But I don't have a clue on how I could load up the "MainView.xib". I can load the "RootViewController", but this only shows the tableview and not the navigation bar.

Thanks in advance!


Solution

  • MainView.xib is usually loaded automatically within the UIApplicationMain function, which is called in your main.m file. If you want to push a view with a navigation bar, you should create a UINavigationController (there's usually no need to subclass), and set your RootViewController object as the navigation controller's root view controller. Or, if you want to do it all in your xib file, you can drag a UINavigationController in and put your root view controller inside it. More info is in the View Controller Programming Guide.