2011-10-09 103 views
1

我一直在尋找幾周,並沒有運氣試圖找到Xcode 4的教程,展示瞭如何將表視圖添加到標籤欄應用程序。我想知道你能否指出我正確的方向?標籤欄中的表視圖應用程序

感謝

+0

這不是xcode4,但它是有幫助的:HTTP: //www.youtube.com/watch?v=LBnPfAtswgw –

回答

2

任何TabBarController教程應該做的,因爲你加UIViewControllers標籤欄。對於表格視圖,只需創建一個UITableViewController。您應該可以將其添加到標籤欄控制器...或任何其他視圖控制器。例如,如果您發現其他一些教程使用navigationController來製作TabBar,只需使用UITableViewController替換教程的navigationController部分即可。 UItableViewControllers上還有大量的文檔和教程。

例如,如果您在app delegate didfinishLaunchingWithOptions中查看此代碼。 Pior爲此,創建了一個MyTableViewController(UITableViewController)和其他一些UIViewController。

// View Controllers for tabController - could be UItableViewControllers or any 
// other UIViewController. You will add this to the tabController 
NSMutableArray *viewControllers = [[NSMutableArray alloc] init]; 

MyTableViewController *myTable = [[MyTableViewController alloc] initWithNibName:@"MyTableViewController" bundle:nil]; 
[viewControllers addObject:myTable]; 

SomeOtherUIViewController *other = [[SomeOtherUIViewController alloc] initWithNibName:@"SomeOtherUIViewController" bundle:nil]; 
[viewControllers addObject:other];  

// add the UIViewControllers to the tabController 
[tabController setViewControllers:viewControllers]; 

// add tabbar and show 
[[self window] addSubview:[tabController view]]; 
[self.window makeKeyAndVisible]; 
return YES; 

然後在每個要添加的TabBar這些視圖控制器,請確保您使用TabBar項添加到他們在初始化

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) 
    { 
     UITabBarItem *barItem = [[UITabBarItem alloc] 
          initWithTitle:@"Progress" 
          image:[UIImage imageNamed:@"report.png"] tag:2]; 

     [self setTabBarItem:barItem]; 
     [barItem release]; 
    } 
    return self; 
} 
相關問題