2011-01-14 7 views
5

のためのシステムイメージを設定することは非常に簡単です:UITabBarControllerのプログラムによる作成とConfigが - プログラム的にアプリでタブバーを作成するタブ

self.tabBarController = [[UITabBarController alloc] init]; 
[self.view addSubview:_tabBarController.view]; 

UIViewController * tab1 = [[UIViewController alloc] init]; 
tab1.title = "A"; 

UIViewController * tab2 = [[UIViewController alloc] init]; 
tab2.title = "B"; 

_tabBarController.viewControllers = [NSArray arrayWithObjects:patientSearch,todoList,nil]; 

[tab1 release]; 
[tab2 release]; 

また、簡単にタブで画像を置くことができます。

tab1.tabBarItem.image = [UIImage imageNamed:@"myIcon.png"]; 

しかし、これらのタブの画像をシステム画像に設定するにはどうすればよいですか? IBでは(例えば、検索、お気に入り、ブックマークなど)これは、このプログラムによって

答えて

10
UITabBarItem *aTabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:0]; 

UITabBarItemがdocs

UITabBarSystemItem システムアイテム「識別子」を変更することで設定されていますが、どのように行うことができますタブバーで使用できます。

typedef enum { 
    UITabBarSystemItemMore, 
    UITabBarSystemItemFavorites, 
    UITabBarSystemItemFeatured, 
    UITabBarSystemItemTopRated, 
    UITabBarSystemItemRecents, 
    UITabBarSystemItemContacts, 
    UITabBarSystemItemHistory, 
    UITabBarSystemItemBookmarks, 
    UITabBarSystemItemSearch, 
    UITabBarSystemItemDownloads, 
    UITabBarSystemItemMostRecent, 
    UITabBarSystemItemMostViewed, 
} UITabBarSystemItem; 

は、それが `tag`のユースケース何​​

+0

設定するには? – Honey

関連する問題