2011-01-14 10 views
5

कोई एप्लिकेशन प्रोग्राम के में एक tabBar बनाने के लिए एक प्रणाली छवि की स्थापना काफी आसान है:Programatic निर्माण और UITabBarController के कॉन्फ़िग - एक टैब

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"]; 

हालांकि मैं इन टैबों की छवि को सिस्टम छवियों में कैसे सेट कर सकता हूं? (जैसे। खोज, पसंदीदा, बुकमार्क आदि) आईबी में इस 'पहचानकर्ता' बदलकर सेट कर दिया जाता है, लेकिन आप यह कैसे प्रोग्राम के

उत्तर

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; 

सेट करने के लिए यह patientSearch.tabBarItem = aTabBarItem;

+0

'tag' के उपयोग के मामले क्या है? – Honey

संबंधित मुद्दे