Add the following code in the AppDelegate. m file to change the Root View Controller.
// Create an object for the navigation bar controller and initialize the Root View UINavigationController * pNavigation = [[UINavigationController alloc] initWithRootViewController: self. viewController]; // use Navigation as the Root View Controller self. window. rootViewController = pNavigation; // release the created object [pNavigation release];
Add code to the-(void) viewDidLoad method in the sub-view. m file to set relevant properties for Navigation.
-(Void) viewDidLoad {[super viewDidLoad]; // name self for the root view. navigationItem. title = @ "Root View"; // set the left and right buttons on the Root View. The association method is empty. You can compile and implement UIBarButtonItem * pLeftBar = [[UIBarButtonItem alloc] initWithTitle: @ "left button" style: adjust target: self action: nil]; UIBarButtonItem * pRightBar = [[UIBarButtonItem alloc] initWithTitle: @ "Right button" style: UIBarButtonItemStylePlain target: self action: nil]; // Add the left and right buttons to the navigation bar self. navigationItem. rightBarButtonItem = pRightBar; self. navigationItem. leftBarButtonItem = pLeftBar; // release the created button object [pRightBar release]; [pLeftBar release];}
@ Property (nonatomic, retain) UIView
// Custom view to use in lieu of a title. May be sizedhorizontally. Only used when item is topmost on the stack.
Use custom views instead of titles. Horizontal dimension. It is only used on the top stack of the product.
An important attribute in the navigation bar that acts as a view. You can perform operations on the view, such as adding a background image, setting the background color, and setting the Selection control.