目前我正在使用ABPeoplePickerNavigationController和UITabbarController,并希望在UITabbarController的索引2中打开ABPeoplePickerNavigationController。
所以在索引2的viewcontroller上,我编写了这样的代码,
-(void)awakeFromNib
{
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
NSMutableArray *newControllers = [NSMutableArray arrayWithArray: [self.tabBarController viewControllers]];
[picker.navigationBar setBarStyle:UIBarStyleBlackOpaque];
[newControllers replaceObjectAtIndex:2 withObject: picker];
[self.tabBarController setViewControllers: newControllers animated: NO];
[picker release];
}
但是当我编写这段代码时,tabbar的标题突然从联系人变为了群组而图片没有显示..
我们如何像以前一样显示此标签栏的标题和图片....
请帮我解决这个问题..
提前致谢...
答案 0 :(得分:1)
请在
中写下此代码 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
方法
[self.window addSubview:tabBarController.view];
UITabBarItem *tabItem = [[[self.tabBarController tabBar] items] objectAtIndex:TAB_INDEX];
[tabItem setTitle:@"Contacts"];
tabItem.image = [UIImage imageNamed:@"YOUR IMAGE"];
快乐编码......