storyboard问题

问题:
用Interface Builder为UITabBarController 设置selected image,运行起来后提示:Could not load the "(null)" image referenced from a nib in the bundle with identifier

Screen-Shot-2014-12-14-at-20.54.18.png

修改方法:
获取制定的tabbar实例,用代码修改
<pre><code>

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    //storyboard每次都创建个新的实例对象,因此需要呈现它 否则不显示
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"main" bundle:[NSBundle mainBundle]];
    UITabBarController * tabBarController = [storyboard instantiateViewControllerWithIdentifier:@"TabBarController"];
    self.window.rootViewController = tabBarController;

    NSArray *imageArray = @[@"ic_tabbar_home",@"ic_tabbar_oversea_red",@"ic_tabbar_faxian_red", @"ic_tabbar_shopping_cart", @"ic_tabbar_my"];
    int i = 0;
    NSArray *itemArray = tabBarController.tabBar.items;
    for (UITabBarItem *item in itemArray) {
    UIImage *image = [UIImage imageNamed:imageArray[i++]];
    item.selectedImage = image;
    }
    tabBarController.tabBar.tintColor = [UIColor redColor];

    return YES;
    }
    </code></pre>

参考:How to set selected images for UITabBarItem in UITabBarController

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容