IOS Study Notes-Navigation bar)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.