2012-06-10 9 views
19

Nel mio file di implementazione AppDelegate Io uso queste righe di codice per impostare font e colori personalizzati di tabBarItems:UITabBarItem appearance -setTitleTextAttributes continua a registrare "lo stato = 1 viene interpretato come UIControlStateHighlighted"?

[[UITabBarItem appearance] setTitleTextAttributes: 
[NSDictionary dictionaryWithObjectsAndKeys: 
[UIColor grayColor], UITextAttributeTextColor, 
[UIFont fontWithName:@"Arial" size:0.0], UITextAttributeFont, 
nil] forState:UIControlStateNormal]; 

[[UITabBarItem appearance] setTitleTextAttributes: 
[NSDictionary dictionaryWithObjectsAndKeys: 
[UIColor whiteColor], UITextAttributeTextColor, 
[UIFont fontWithName:@"Arial" size:0.0], UITextAttributeFont, 
nil] forState:UIControlStateHighlighted]; 

Per qualche motivo (sconosciuto) i seguenti messaggi vengono registrati, uno per ogni tabBarItem:

button text attributes only respected for UIControlStateNormal, UIControlStateHighlighted and UIControlStateDisabled. state = 1 is interpreted as UIControlStateHighlighted. 

Impossibile trovare nulla utilizzando i motori di ricerca standard, quindi cerco il tuo aiuto. Cosa sto sbagliando e come risolverlo?

Grazie in anticipo per eventuali suggerimenti.

+0

Anche il mio ha lo stesso problema. Penso che lo ignoriamo. Ma è davvero fastidioso se hai bisogno di vedere altri messaggi nella console. Puoi vedere questa discussione: http://www.iphonedevsdk.com/forum/iphone-sdk-development/105017-uitabbaritem-logging-state-1-interpreted-uicontrolstatehighlighted.html –

+5

Leggendo la risposta di Camille, sostituisco "UIControlStateHighlighted" con "UIControlStateSelected" e il messaggio è sparito. Sembra diverso dalla risposta di Camille, ma il mio caso è "UITabBarItem" mentre Camille è per "UIBarButtonItem". –

+1

Wayne Liu, dovresti postare come risposta imho. Sembra che l'avviso della console sia davvero fuorviante. Per 'titleTextAttributes' su un UITabBar gli stati accettati sembrano essere' UIControlStateNormal', 'UIControlStateSelected' e' UIControlStateDisabled'. Ma non "UIControlStateHighlighted" come suggerisce l'avviso. – Lukas

risposta

5

Ho avuto lo stesso problema perché stavo usando:

[[UIBarButtonItem appearance] setTitleTextAttributes: 
[NSDictionary dictionaryWithObjectsAndKeys: 
    [UIColor whiteColor], UITextAttributeTextColor, nil] forState:UIControlStateSelected]; 

ho cambiato in:

[[UIBarButtonItem appearance] setTitleTextAttributes: 
[NSDictionary dictionaryWithObjectsAndKeys: 
    [UIColor whiteColor], UITextAttributeTextColor, nil] forState:UIControlStateHighlighted]; 

... e il problema è andato via. Spero che questo ti aiuti!

52

Basta cambiare "UIControlStateHighlighted" in "UIControlStateSelected". Spero che questo ti aiuti!

+0

male (: ... ha funzionato per me. – Ans

+1

funziona. È come se facessero lo stesso lavoro, quindi perché Apple mantiene entrambi? – thedp

Problemi correlati