2016-11-10 2 views
2

から私は両方のライン怒鳴るを試みたが、それはすべてのを起こしたときに[UITabBar setUnselectedItemTintColor:]:認識されていないセレクタはインスタンスクラッシュアプ​​リコールsetUnselectedItemTintColorはUITabBar

[self.tabBar setUnselectedItemTintColor:[UIColor blackColor]]; 
[[UITabBar appearance] setUnselectedItemTintColor:[UIColor blackColor]]; 

任意の提案に送信されましたか?

+2

を試してみて、それが 'Availibility示す:iOS版(10.0以降)、tvOS(10.0以降)'。 端末のiOSバージョン番号は何ですか? – nynohu

+0

iOS 9.0デバイスを使ってテストしました。アン、私は答えを見つけた。 –

+1

あなたは答えを受け入れるべきです。 @JaredChu – Mahesh

答えて

7

この方法はiOS 10でのみ利用可能ですので、以前のバージョンではクラッシュします。呼び出し前にメソッドの可用性をチェックする必要があります。

if ([[UITabBar appearance] respondsToSelector:@selector(setUnselectedItemTintColor:)]) { 
    [[UITabBar appearance] setUnselectedItemTintColor:[UIColor blackColor]]; 
} 
+0

iOS 9.0デバイス用のソリューションはありますか?あなたのコードはそれで動作しないので。 –

+0

@JaredChu古いバージョンのiOSについては、次の解決策を確認してください。http://stackoverflow.com/a/18433996/1689376 – alexburtnik

+1

外観のプロキシが信頼できないため、次の回答がうまく機能しています。http://stackoverflow.com/questions/ 12504304/respondstoselector-appear-for-appearance-proxy – iOSDevil

0

クイックヘルプ]タブでこの

if ([[UITabBar appearance] respondsToSelector:@selector(setUnselectedItemTintColor:)]) 
    { 
     [[UITabBar appearance]setUnselectedItemTintColor:AppYellowColor]; 
    } 
    else 
    { 
     [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:AppYellowColor, NSForegroundColorAttributeName, nil] forState:UIControlStateNormal]; 
    } 
関連する問題