简体   繁体   English

标签栏图标不会出现(这些限制有哪些?)

[英]Tab Bar Icon does not appear (what are the restrictions on these?)

Well, this is no doubt silly, but I can't get my tab bar icon to show up. 好吧,这无疑是愚蠢的,但是我无法显示我的标签栏图标。

Here is the code: 这是代码:

- (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
// Misc stuff deleted
[self.nibBundle loadNibNamed:nibNameOrNil owner:self options:nibOptions];

if (self) {
    self.title = NSLocalizedString(@"Play Game", @"Play Game");
    self.tabBarItem.image = [UIImage imageNamed:@"GVC.png"];
}

[self awakeFromNib];
return self;

} }

Which, if I give it the name of a too-large icon, the system inserts a blue placeholder. 如果我给它指定了太大的图标,系统会插入一个蓝色的占位符。 So I think my code is fine (and it looks like everyone elses'). 因此,我认为我的代码很好(看起来像其他人的代码一样)。

This is for iOS 5 and I have a non-retina display. 这是用于iOS 5的设备,并且具有非视网膜显示屏。 I have experimented with sizes, including the ideal 30 x 30 size . 我已经尝试过尺寸,包括理想的30 x 30尺寸 By the way, all other icons & images are performing properly. 顺便说一下,所有其他图标和图像均正常运行。 The icons are listed in the plist under Icon Files (iOS 5) -> Primary Icon -> Icon Files and the names include .png If I change "Play Game" the app changes accordingly. 图标列在图标文件(iOS 5)->主图标->图标文件下的plist中,名称包括.png如果我更改“ Play Game”,则应用程序也会相应更改。 I've been using Inkscape to make the icons. 我一直在使用Inkscape制作图标。

So my questions are 所以我的问题是

  1. Any ideas generally? 一般有什么想法吗? and, 和,
  2. What are the restrictions on the tab bar icon? 标签栏图标有哪些限制?

I know size, I gather it must be b/w but have a hard time finding documentation that says so. 我知道尺寸,我认为尺寸一定是黑白的,但是很难找到这样的文档。 Any limitations on name, must it be square or can it be rectangular, etc? 名称有任何限制,必须是正方形还是矩形? I've read too that they must be used like an alpha mask but I'm not sure what that really means when I'm making the image. 我也读过它们必须像alpha蒙版一样使用,但是我不确定在制作图像时这实际上意味着什么。

As I said, silly. 就像我说的那样 I was not adding the icons to the project from within Xcode... Maybe this will help some other goof ball! 我不是在Xcode中将图标添加到项目中的……也许这将对其他一些问题有所帮助!

check the file name. 检查文件名。 The device is case-sensitive and the simulator is not. 该设备区分大小写,而模拟器不区分大小写。

Also check the following post for additional info: UITabBar images visible on simulator, disappear on the device 另外,请检查以下帖子以获取其他信息: UITabBar图像在模拟器上可见,在设备上消失

I had the same problem and solved it like this. 我有同样的问题,并像这样解决了。

For example, I have an app contains several tabs. 例如,我有一个包含多个选项卡的应用程序。 One of them is CardViewController. 其中之一是CardViewController。 The image is cards and the name of the tab is "Cards". 图像是卡片,选项卡的名称是“卡片”。 I add these code into the CardViewController. 我将这些代码添加到CardViewController中。 Here you make sure that the image is set. 在这里,请确保已设置图像。 After this change the image should show up. 更改之后,图像应显示出来。

required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)

    // Initialize Tab Bar Item
    tabBarItem = UITabBarItem(title: "Cards", image: UIImage(named: "cards"), tag: 0)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM