我正在使用自定义UINavigationBar处理选项卡式应用程序。每当我在iOS模拟器中打开控制中心时,Xcode中的命令行都会给我以下错误:
CGImageCreate:图片大小无效0 x 0。
它出现在每个ViewController中,即使是空的。
这是否可以使用自定义UINavigationBar或TabBar执行某些操作?
这是我用于标签栏的appdelegate.m文件中的代码
DMFirstViewController *firstViewController = [[DMFirstViewController alloc] init];
DMSecViewController *secondViewController = [[DMSecViewController alloc] init];
DMThirdViewController *thirdViewController = [[DMThirdViewController alloc] init];
DMFourthViewController *fourthViewController = [[DMFourthViewController alloc] init];
tabController = [[UITabBarController alloc] init];
NSArray* controllers = [NSArray arrayWithObjects:firstViewController, secondViewController, thirdViewController, fourthViewController, nil];
tabController.viewControllers = controllers;
UIImage *unselectedTabFirst = [UIImage imageNamed:@"first_line.png"];
UIImage *selectedTabFirst = [UIImage imageNamed:@"first_active.png"];
UIImage *unselectedTabSec = [UIImage imageNamed:@"second_line.png"];
UIImage *selectedTabSec = [UIImage imageNamed:@"second_active.png"];
UIImage *unselectedTabThird = [UIImage imageNamed:@"third_line.png"];
UIImage *selectedTabThird = [UIImage imageNamed:@"third_active.png"];
UIImage *unselectedTabFourth = [UIImage imageNamed:@"fourth_line.png"];
UIImage *selectedTabFourth = [UIImage imageNamed:@"fourth_active.png"];
unselectedTabFirst = [unselectedTabFirst imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
selectedTabFirst = [selectedTabFirst imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
unselectedTabSec = [unselectedTabSec imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
selectedTabSec = [selectedTabSec imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
unselectedTabThird = [unselectedTabThird imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
selectedTabThird = [selectedTabThird imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
unselectedTabFourth = [unselectedTabFourth imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
selectedTabFourth = [selectedTabFourth imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
firstViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"first" image:unselectedTabFirst selectedImage:selectedTabFirst];
secondViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"second" image:unselectedTabSec selectedImage:selectedTabSec];
thirdViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"third" image:unselectedTabThird selectedImage:selectedTabThird];
fourthViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"fourth" image:unselectedTabFourth selectedImage:selectedTabFourth];
答案 0 :(得分:5)
正如链接显示来自Retro,这只发生在iOS模拟器中。在开发者设备上运行应用程序不会产生此错误。
问题解决了!