0

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. I have experimented with sizes, including the ideal 30 x 30 size. 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. I've been using Inkscape to make the icons.

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.

4

3 回答 3

0

As I said, silly. I was not adding the icons to the project from within Xcode... Maybe this will help some other goof ball!

于 2012-07-20T03:35:31.323 回答
0

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

于 2013-02-18T18:30:06.383 回答
0

I had the same problem and solved it like this.

For example, I have an app contains several tabs. One of them is CardViewController. The image is cards and the name of the tab is "Cards". I add these code into the 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)
}
于 2016-11-20T08:45:32.563 回答