我一直在試圖改變我的選項卡的標題用下面的代碼,更改標題中的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
嗨抱歉後期靠,這工作,但它也改變了標題欄標題? –