gpt4 book ai didi

ios - 打开控制中心时CGImageCreate : invalid image size 0 x 0,

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:29:13 25 4
gpt4 key购买 nike

我正在开发一个带有自定义 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];

最佳答案

正如 Retro 中的链接所示,这仅发生在 iOS 模拟器中。在开发者设备上运行应用不会产生此错误。

问题解决了!

关于ios - 打开控制中心时CGImageCreate : invalid image size 0 x 0,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20146291/

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