我想在选项卡中使用新的Storyboard引用。当我使用Storyboard引用时,自定义图像和文本设置的UITabBarItem没有显示任何内容。请参见设置:
故事板设置我通过在引用的故事板中的初始视图控制器的initWithCoder函数中设置图像和标题来解决了这个问题,如下所示:
static NSString *const ContactsViewControllerTabContactImageName = @"tab-contact";
static NSString *const ContactsViewControllerTabContactActiveImageName = @"tab-contact-active";
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
self.title = NSLocalizedString(@"Contacts", nil);
self.tabBarItem.image = [UIImage imageNamed:ContactsViewControllerTabContactImageName];
self.tabBarItem.selectedImage = [UIImage imageNamed:ContactsViewControllerTabContactActiveImageName];
}
return self;
}