(1) Scenario: In iOS8.1, we usually use the following statement to set the Global navigation bar button item's theme
Uibarbuttonitem *item=[uibarbuttonitem appearance]; Nsmutabledictionary *textattrs=[nsmutabledictionary dictionary];textattrs[nsforegroundcolorattributename]=[ Uicolor Orangecolor]; [item Settitletextattributes:textattrs Forstate:uicontrolstatenormal]; [item Settitletextattributes:textattrs forstate:uicontrolstatehighlighted]; Nsmutabledictionary *dtextattrs=[nsmutabledictionary Dictionarywithdictionary:textattrs];d textattrs[ Nsforegroundcolorattributename]=[uicolor Graycolor]; [item Settitletextattributes:dtextattrs forstate:uicontrolstatedisabled];
(2) The problem is that we clearly set the properties (normal,highlighted and disabled) on the item in various States, but when we add an item to a controller and set it to the disabled state, we find that it does not work.
-(void) setupnavbar{ self.navigationitem.rightbarbuttonitem=[[uibarbuttonitem alloc]initwithtitle:@ "send" style : Uibarbuttonitemstyledone target:self Action: @selector (send)]; Self.navigationitem.rightbarbuttonitem.enabled=no;}
(3) Solutions
Place the above statement set to Disabled in Viewwillappear.
-(void) Viewwillappear: (BOOL) animated{ [Super viewwillappear:animated]; If the following sentence is written in viewdidload, disabled's item color has no effect self.navigationitem.rightbarbuttonitem.enabled=no;}
(4) As to why this is so? To tell the truth, I'm not quite sure what I thought was the reason for the call order (normal test order), which was later thought to be viewdidload in the enabled unassigned (but the test is 0 and has an assignment). Please advise me if you have the understanding. Think of it as a bug in iOS8.1. It is normal to test in iOS7.1.
iOS development FIX: Uibarbuttonitem settitletextattributes in iOS8.1 is not valid for disabled color setting