我一直在试图改变我的选项卡的标题用下面的代码,更改标题中的UITabBarController
- (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
嗨抱歉后期靠,这工作,但它也改变了标题栏标题? –