カスタマイズされた UITabBar があり、AppDelegate で次のコードを使用します。
- (void)tabBarController:(MainUITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
[self customizeTabBar];
}
- (void)customizeTabBar {
NSLog(@"*******customizeTabBar*******");
UIImage *tabBackground = [[UIImage imageNamed:@"unselectedtab"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
// Set background for all UITabBars
[[UITabBar appearance] setBackgroundImage:tabBackground];
// Set tint color for the images for all tabbars
[[UITabBar appearance] setSelectedImageTintColor:[UIColor whiteColor]];
// Set selectionIndicatorImage for all tabbars
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"selectedtab"]];
}
- (void)tabBarController:(MainUITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed
{
NSLog(@"*******didEndCustomizingViewControllers*******");
}
これは iOS5 以降では問題ありませんが、7 では最初の TabBarItem の最初のロード時にアイテム インジケータが白く、ボタンが選択されているように見えますが、「selectedTab」イメージはロードされません。
別のタブを押すと、新しいタブが赤くなり、正しく表示されます。これは、最初のタブ バー項目またはその後に選択されたタブ バー項目と同様です。最初の起動時にのみ機能しません。
CustomizeTabBar が呼び出されますが、選択した画像は最初の起動時に表示されません。
didEndCustomizingViewControllers はまったく呼び出されないようです。
これは、iOS7 のエミュレータまたはデバイスでは機能しませんが、iOS5、6 では機能します。
何か案は?前もって感謝します。