0

UITab 栏中没有显示图标,而是显示了一些矩形。可能是什么问题呢?

我的代码:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
   self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  if (self) {
    self.tabBarItem.image = [UIImage imageNamed:@"poolmate.png"];
}
return self;
}
4

1 回答 1

0

你从来没有初始化你的tabBarItem. 尝试这个:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.tabBarItem = [self tabBarItem];
        self.tabBarItem.image = [UIImage imageNamed:@"poolmate.png"];
    }
    return self;
}
于 2012-11-05T02:26:12.617 回答