Iphone UITabBarItem 图像未显示
我的问题是如何添加 UITabBarController 的 childViewController 的图标。我的代码是:
UITabBarController *tabBar=[[UITabBarController alloc]init];
MyUIViewController *mc=[[MyUIViewController alloc]init];
[tabBar addChildViewController:mc];
[self.navigationController pushViewController:tabBar animated:YES];
提前致谢。
My question is how I could add the icon of a childViewController of an UITabBarController. My code is:
UITabBarController *tabBar=[[UITabBarController alloc]init];
MyUIViewController *mc=[[MyUIViewController alloc]init];
[tabBar addChildViewController:mc];
[self.navigationController pushViewController:tabBar animated:YES];
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请尝试这个
Please try this
我通过在 MyUIViewController: 中添加属性和属性解决了这个问题:
然后用图像初始化它:
I have solved this by adding an attribute and property in MyUIViewController:
and then initialize it with an image:
我刚刚发现桌面不区分大小写,但是设备要求代码具有相同的字母数字大小写(大写/小写)。确保文件名相同......具体到大小写(大写/小写)!
示例:
“first.png”在磁盘上的文件名最好表示为 -->
self.tabBarItem.image = [UIImage imageNamed:@"first"];
不是 -- 不是 --- 不是
self.tabBarItem.image = [UIImage imageNamed:@"First"];
今天大写的“F”踢了我三个小时!由于这个疏忽,我今天损失了 3 个小时的生命。希望这对其他人有帮助。
I just discovered that the desktop is case insensitive, however the device requires the code to have the same alpha-numberic case (upper/lower). Make sure the name of the file is the same ... down to the case (upper/lower)!
Example:
The file name on disk of "first.png" had better be represented as -->
self.tabBarItem.image = [UIImage imageNamed:@"first"];
NOT -- NOT --- NOT
self.tabBarItem.image = [UIImage imageNamed:@"First"];
The capital 'F' kicked my arse for 3 hours today! I lost 3 hours of my life today because of this oversight. Hope this helps someone else.