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
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