我一直在尝试使用以下代码更改标签的标题,
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = @"City Search";
self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:1];
}
delegate = (AWSAppDelegate *)[[UIApplication sharedApplication] delegate];
return self;
}
这给了我一个 iOS 原生搜索图标和测试。但我想做的是添加自己的标题,我尝试执行以下操作,
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.tabBarItem = [[UITabBarItem alloc] init]
self.tabBarItem.image = myImage;
self.tabBarItem.title = @"FooBar";
}
delegate = (AWSAppDelegate *)[[UIApplication sharedApplication] delegate];
return self;
}
然而,这只是给了我一个没有任何文本的空白标签,其他一切正常。你能帮忙吗?我在用着iOS 6