我有app我在哪里使用标签栏控制器。对于标签栏按钮,我的图像大小为30x30和60x60。
当我在iOS 6中运行我的应用程序时,它会显示我选择的图像,但是当我切换到iOS 7时,它不会显示我选择的选项卡图像。知道为什么会这样吗?
以下是相同的截图。
在进一步调查中,我发现只有前两个标签栏才会发生这种情况。从第三到第五,iOS7显示图像正常。
使用的代码是
UIImage *selectedImage0 = [UIImage imageNamed:@"home_selected.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"home.png"];
UIImage *selectedImage1 = [UIImage imageNamed:@"search_selected.png"];
UIImage *unselectedImage1 = [UIImage imageNamed:@"search.png"];
UIImage *selectedImage2 = [UIImage imageNamed:@"ad_with_us_selected.png"];
UIImage *unselectedImage2 = [UIImage imageNamed:@"ad_with_us.png"];
UIImage *selectedImage3 = [UIImage imageNamed:@"aboutus_selected.png"];
UIImage *unselectedImage3 = [UIImage imageNamed:@"aboutus.png"];
UIImage *selectedImage4 = [UIImage imageNamed:@"contacts_selected.png"];
UIImage *unselectedImage4 = [UIImage imageNamed:@"contacts.png"];
UITabBar *tabBar = self.tabBarController.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
UITabBarItem *item2 = [tabBar.items objectAtIndex:2];
UITabBarItem *item3 = [tabBar.items objectAtIndex:3];
UITabBarItem *item4 = [tabBar.items objectAtIndex:4];
[[UITabBar appearance] setSelectionIndicatorImage:[[UIImage alloc] init]];
[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
[item1 setFinishedSelectedImage:selectedImage1 withFinishedUnselectedImage:unselectedImage1];
[item2 setFinishedSelectedImage:selectedImage2 withFinishedUnselectedImage:unselectedImage2];
[item3 setFinishedSelectedImage:selectedImage3 withFinishedUnselectedImage:unselectedImage3];
[item4 setFinishedSelectedImage:selectedImage4 withFinishedUnselectedImage:unselectedImage4];
以下也不适用于iOS 7。
[tabItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:localize(@"fontNameN") size:10.0f], NSFontAttributeName, [UIColor greenColor], NSForegroundColorAttributeName,nil] forState:UIControlStateSelected];
和forState:UIControlStateHighlighted
也是
我在Xcode 4.2中创建了这个项目,现在在iOS 7中,我在Xcode 5中打开了。这会有问题吗?
答案 0 :(得分:1)
只需使用
[item0 setSelectedImage:selectedImage0];
依此类推,因为
setFinishedSelectedImage:withFinishedUnselectedImage:
iOS 7中已弃用
答案 1 :(得分:0)
当我从IB中移除Title
和Image
中默认的文字时,现在一切正常。
Apple只知道问题是什么