问题与ios7 tabbar控制器 [英] issue with ios7 tabbar controller

查看:135
本文介绍了问题与ios7 tabbar控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我正在将我的应用程序从ios 6.1迁移到7,该应用程序包含一个tabbar控制器,在ios6上完美运行,但是当我在ios 7上运行时,5个tabbar项目中的4个不显示所选图像,非常奇怪,因为一个人正确显示而其他人没有,我正在使用故事板,我无法使用imageWithRenderingMode:因为我仍然在xcode 4.6上这样做,所以我想在xcode 4.6中纠正它并且是能够在ios7上运行它,tabbarcontroller的代码被给出,请原谅错误,如果有的话..

hi i am migrating my app from ios 6.1 to 7, the app contains a tabbar controller, works perfectly fine on ios6, but when i run this on ios 7, 4 among the 5 tabbar items dont show the selected image, its being pretty weird as one is showing correctly while the others are not, am using storyboard, am not able to use "imageWithRenderingMode:" as i am still doing this on xcode 4.6, so i would like to rectify it in xcode 4.6 only and be able to run it on ios7, the code for the tabbarcontroller is given, please forgive mistake if any..

- (void)customizeTabbarBackgroundImages:(UITabBarController *)tabbarController
{
    //background of tabbar
    [tabbarController.tabBar setBackgroundImage:[UIImage imageNamed:@"tabbarBackground.png"]];

    //background for selected item
    [[tabbarController tabBar] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar-selection-background.png"]];

    //keep the item at index 2 as selected item
    tabbarController.selectedIndex = 2;
}


- (void)customizeTabbarItemImages:(UITabBarController *)tabbarController
{
    {
        //Index - Favourites
        [[tabbarController.tabBar.items objectAtIndex:0] setFinishedSelectedImage:[UIImage imageNamed:@"tabbar-favourites-icon-down.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar-favourites-icon.png"]];

        //Index - Search
        [[tabbarController.tabBar.items objectAtIndex:1] setFinishedSelectedImage:[UIImage imageNamed:@"tabbar-search-icon-down.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar-search-icon.png"]];

        //Index - Icon
        [[tabbarController.tabBar.items objectAtIndex:2] setFinishedSelectedImage:[UIImage imageNamed:@"tabbar-random-button"]withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar-random-button"]];

        //Index - Profile
        [[tabbarController.tabBar.items objectAtIndex:3] setFinishedSelectedImage:[UIImage imageNamed:@"tabbar-profile-icon-down.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar-profile-icon.png"]];

        //Index - Settings
        [[tabbarController.tabBar.items objectAtIndex:4] setFinishedSelectedImage:[UIImage imageNamed:@"tabbar-settings-icon-down.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar-settings-icon.png"]];
    }
}

推荐答案

您正在想要使用imageWithRenderingMode。只需做这样的事情来调整UIImage以兼容两个ios版本:

You're on the right track with wanting to use imageWithRenderingMode. Just do something like this to adjust the UIImage to be compatible with both ios versions:

UIImage *tabImage = [UIImage imageNamed:@"tabBar.png"];

if ([UIImage instancesRespondToSelector:@selector(imageWithRenderingMode:)]) {
    tabImage = [segmentImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}

这篇关于问题与ios7 tabbar控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆