No navigation-based application exists in xcode4.2, instead of the master-detailapplication. When we create the application on the iPhone, we can get a navigation application.Program, Which is a uitabelview as the root view, but we prefer the version in the old version.
1. Create a master-detailapplication Program
2. Deleted the uitableview-based controller.
3. Create a mainwindow. XIB File
4. create our own rootviewcontroller, which inherits from uiviewcontroller.
The current project structure should be:
5. Modify appdelegate. h and appdelegate. M.
Appdelegate. h:
# Import <uikit/uikit. h>
@ Interface appdelegate: uiresponder <uiapplicationdelegate> {
Uiwindow * window;
Uinavigationcontroller * navigationcontroller;
}
@ Property (nonatomic, retain) iboutlet uiwindow * window;
@ Property (nonatomic, retain) iboutlet uinavigationcontroller * navigationcontroller;
@ End
Appdelegate. M:
Major changes:
-(Bool) Application :( uiapplication *) Application didfinishlaunchingwitexceptions :( nsdictionary *) launchoptions
{
[Self. Window addsubview: navigationcontroller. View];
[Self. Window makekeyandvisible];
Return yes;
}
6. Modify the mainwindow. XIB File
1) Add an object, window, and navigation controller from the control panel.
2) file's owner
3) object
4) Navigation Controller
Modify the viewcontroller
Add a bar button item to the navigation item.
7. Modify project properties
Last: