2012-01-11 13 views
0

我最近回到本地iOS開發,並且正在使用Tab Bar應用程序。我注意到構建一個的過程已經改變。所有的教程都提到將一個Tab Bar控制器添加到基於Window的應用程序的mainwindow.xib中。我真的很喜歡使用界面生成器系統來創建一個標籤欄,但這似乎是過去的事情?新的iOS tabbars

沒有初始窗口來添加標籤欄控制器它是一種靜音點。標籤欄模板並不壞,它只是使用代碼來設置每個視圖標籤欄元素等。這很好,但我真的很喜歡將界面和代碼分離的方法。當我與客戶合作時,很高興向他們展示可視化界面的變化。

我的問題是1)是否有可能仍然使用標籤欄控制器和界面構建來定製我的標籤欄來構建標籤欄應用程序? 2)我如何去做這件事?有沒有任何教程?我並不反對使用空模板從頭開始構建。

感謝,

大衛

+0

您使用的是什麼版本的Xcode?我們現在達到了4.2,並使用了故事板。真是一個活着的時間。 – 2012-01-11 21:05:10

+0

也許故事登機是我正在尋找的。 – 2012-01-11 22:04:04

回答

0

你好我覺得這個教程將幫助您:

在iOS5中的自定義很簡單:

vistit:http://kurrytran.blogspot.com/2011/10/ios-5-tutorial-creating-custom-tab-bar.html

它是所有完成故事板,然後在viewdidload方法中設置所有內容。

- (void)viewDidLoad 
{ 
    UIImage *selectedImage0 = [UIImage imageNamed:@"HomeDB.png"]; 
    UIImage *unselectedImage0 = [UIImage imageNamed:@"HomeLB.png"]; 

    UIImage *selectedImage1 = [UIImage imageNamed:@"ScheduleDB.png"]; 
    UIImage *unselectedImage1 = [UIImage imageNamed:@"ScheduleLB.png"]; 

    UIImage *selectedImage2 = [UIImage imageNamed:@"BuildingsDB.png"]; 
    UIImage *unselectedImage2 = [UIImage imageNamed:@"BuildingsLB.png"]; 

    UIImage *selectedImage3 = [UIImage imageNamed:@"InformationDB.png"]; 
    UIImage *unselectedImage3 = [UIImage imageNamed:@"InformationLB.png"]; 

    UIImage *selectedImage4 = [UIImage imageNamed:@"MoreDB.png"]; 
    UIImage *unselectedImage4 = [UIImage imageNamed:@"MoreLB.png"]; 

    UITabBar *tabBar = self.tabBarController.tabBar; 
    UITabBarItem *item0 = [tabBar.items objectAtIndex:0]; 
    UITabBarItem *item1 = [tabBar.items objectAtIndex:1]; 
    UITabBarItem *item2 = [tabBar.items objectAtIndex:2]; 
    UITabBarItem *item3 = [tabBar.items objectAtIndex:3]; 
    UITabBarItem *item4 = [tabBar.items objectAtIndex:4]; 

    [item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0]; 
    [item1 setFinishedSelectedImage:selectedImage1 withFinishedUnselectedImage:unselectedImage1]; 
    [item2 setFinishedSelectedImage:selectedImage2 withFinishedUnselectedImage:unselectedImage2]; 
    [item3 setFinishedSelectedImage:selectedImage3 withFinishedUnselectedImage:unselectedImage3]; 
    [item4 setFinishedSelectedImage:selectedImage4 withFinishedUnselectedImage:unselectedImage4]; 
    [super viewDidLoad]; 
     // Do any additional setup after loading the view, typically from a nib. 
} 

我希望它有幫助。

+0

OP正在討論通過接口生成器實例化一個'UITabBarController',而不是修改外觀。 – 2012-01-11 21:04:43