IOS Uinavigationcontroller Add left and right buttons do not show problem solution

Source: Internet
Author: User

One. Scene simulation

We have a uinavigationcontroller and a uiviewcontroller that initialize these two at the start of the program, the code is as follows

Homeviewcontroller *homecon = [[Homeviewcontroller alloc] init]; Initialize Uiviewcontrolleruinavigationhomebar *homenavigation = [[Uinavigationhomebar alloc] Initwithrootviewcontroller:            Homecon]; Initialize Uinavigationcontroller

Next, when we add the left and right buttons in the Uinavigationcontroller, there is no effect, the code is as follows

This is Uinavigationcontroller's viewdidload in Uibarbuttonitem *bill = [[Uibarbuttonitem alloc] initwithtitle:@ "Bill" style: Uibarbuttonitemstyleplain Target:nil action:nil];self.navigationitem.rightbarbuttonitem = Bill;

Run Invisible button

Two. Problem solving

    1. See Navigationitem's instructions first

@property (Nonatomic,readonly,retain) Uinavigationitem *navigationitem; Created On-demand So, a view controller may customize its navigation appearance.

Say: Created when the program is needed, and if there is a viewcontroller it may block the item in the current navigation


2. Workaround

Since item in Uinavigationcontroller is not available, you need to use item in Uiviewcontroller

The Create button is written to the Uiviewcontroller Viewdidload

-(void) viewdidload {[Super viewdidload];    Do any additional setup after loading the view.        Self.title = @ "title"; Add Billing button Uibarbuttonitem *bill = [[Uibarbuttonitem alloc] initwithtitle:@ "Billing" Style:uibarbuttonitemstyleplain target:n    Il action:nil]; Self.navigationItem.rightBarButtonItem = Bill;}

Three. Navigation the color of the left and right buttons is not the same as the title color solution

Add a sentence to the viewdidload of navigation

[[Uinavigationbar appearance] Settintcolor:[uicolor Whitecolor]];

Can


IOS Uinavigationcontroller Add left and right buttons do not display problem resolution

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.