2009-05-04 15 views
0

私はインターフェイスビルダーの私のUITabBarControllerにビューコントローラを追加しました。プログラムを追加してアイテムのタイトルを変更するにはどうすればよいですか?UITabBarに画像を追加

答えて

3

appDelegate.mファイルの 'applicationDidFinishLaunching:'機能で追加できます。例えば

NSInteger index = 0; 
while(index < 4){ // 4 is the number of tabbar items 
    UINavigationController *navCtrlr = (UINavigationController*)[[tabBarController viewControllers] objectAtIndex:index]; 
    UITabBarItem *tabBar = (UITabBarItem *) navCtrlr.tabBarItem; 
    if(index == 0){ 
     tabBar.image = [UIImage imageNamed:@"home-item.png"]; 
     tabBar.title = @"home"; 
    } 
    ... 
    index ++; 
}