gpt4 book ai didi

ios - xcode 6 自定义标签栏在选择图像之前不显示图像

转载 作者:行者123 更新时间:2023-11-28 21:51:31 28 4
gpt4 key购买 nike

我有几个几年前写的应用程序,它们都在商店里,一切正常,工作正常,已批准等。

我现在已经在 Xcode 6 中打开它们以对它们进行一些更新,而我编写并在 Xcode 4 中正常工作的自定义标签栏现在显示出非常奇怪的行为。

该栏在第一次加载时显示为空白,但是当触摸/选择每个选项卡时,图像就会加载。一旦所有选项卡都被选中一次,该栏就会完全正常工作并且所有图像都按预期显示 - 但在第一次加载时,选项卡栏显示空白(第一个选项卡除外,因为它已被选中)。

enter image description here

代码自从它以前工作以来没有改变,所有图像都在那里并且加载正常,因为一旦选择了一个选项卡,它们就会正常显示。只有在第一次加载时才会显示图像,直到触摸并选择该选项卡。

我的这个自定义标签栏的代码如下,之前一切正常,现在在商店的应用程序中也能正常工作:

CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;
CGRect tabbarTopFrame = CGRectMake(0,(screenSize.height - 59),320,10);
UIImageView *tabbarTop = [[UIImageView alloc] initWithFrame:tabbarTopFrame];
tabbarTop.image = [UIImage imageNamed:@"tabbar_top.png"];
[self.tabBarController.view addSubview:tabbarTop];

UIImage *selectedImage0 = [UIImage imageNamed:@"tabbar_introduction_active.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"tabbar_introduction_default.png"];
UIImage *selectedImage1 = [UIImage imageNamed:@"tabbar_nests_active.png"];
UIImage *unselectedImage1 = [UIImage imageNamed:@"tabbar_nests_default.png"];
UIImage *selectedImage2 = [UIImage imageNamed:@"tabbar_home_active.png"];
UIImage *unselectedImage2 = [UIImage imageNamed:@"tabbar_home_default.png"];
UIImage *selectedImage3 = [UIImage imageNamed:@"tabbar_dogowners_active.png"];
UIImage *unselectedImage3 = [UIImage imageNamed:@"tabbar_dogowners_default.png"];
UIImage *selectedImage4 = [UIImage imageNamed:@"tabbar_spotted_active.png"];
UIImage *unselectedImage4 = [UIImage imageNamed:@"tabbar_spotted_default.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];

item0.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
item1.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
item2.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
item3.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
item4.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);

[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];

关于上述代码,自 Xcode 4 以来发生了哪些变化,或者上述代码是否存在任何问题,导致图像在被选中之前无法加载?

Xcode 显示的代码没有错误或警告。

这让我悲痛欲绝,我无法理解这种行为!

最佳答案

[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];

该函数在 iOS7 中首先被弃用。

备选方案:

[item0 setImage:[unselectedImage0 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

[item0 setSelectedImage:[selectedImage0 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

关于ios - xcode 6 自定义标签栏在选择图像之前不显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28126463/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com