2013-12-12 26 views
0

的UISearchBar setBarTintColor無法識別的選擇例外,我有一個例外,在iOS6的:在iOS6的

-[UISearchBar setBarTintColor:]: unrecognized selector sent to instance 0xad94250 

,但我沒有在我的代碼這種方法。我該如何解決這個問題?

+0

你可以做有條件檢查,看看你是否在iOS7或更低。 如果你在iOS6上使用'tintColor',否則在iOS7中使用'barTintColor' –

回答

5

barTintColor可用的iOS 7及以上的,所以它會爲IO7及以上的只有

@property(nonatomic,retain) UIColor *barTintColor NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR; // default is nil 

對於iOS 6.1工作,並降低你必須使用

@property(nonatomic,retain) UIColor *tintColor; 
0

我忘記了屬性。

self.searchBar.barTintColor = [UIColor whiteColor];