No Icon shows up after adding images to view controllers


#1

Hi.
I typed the code in the book, everything sounds fine except I can not see why there is no Icon in the tab bar.

Here is my code for the init method of CurrentTimeViewController

  • (id)init
    {
    self = [super initWithNibName:nil bundle:nil];
    if (self) {
    // Initialization code here.
    UITabBarItem *tbi=[self tabBarItem];
    [tbi setTitle:@“Time”];

       NSLog(@"before time image");
      UIImage *i=[UIImage imageNamed:@"Time.png"];
      [tbi setImage:i];
      NSLog(@"after time image");
    

    }

    return self;
    }

Thank you.


#2

Hi ketabkhor,

did you add the Time.png to the project?
Apparently imageNamed silently fails if the image file is not in the bundle. In this case your tab will have no image.

Click on the HypnoTime project and the Build Phases tab.
Make sure Time.png is in the Copy Bundle Resources.

Good luck,
K


#3

:blush:
I think that is the problem!
Thank you!