2011-10-24 94 views
1

我正在嘗試使用NSMutableArray填充tableview,而且我很難用它進行填充。如何使用NSMutableArray填充rootviewcontroller tableview

這應該是簡單的我在想,但我不能得到它的工作。

任何幫助,將不勝感激。

謝謝

+3

周圍有淨SOOOOO很多教程,甚至在計算器上創建一個簡單的表視圖。你應該搜索一下!以下是Google上的首次搜索結果:http://www.iphonesdkarticles.com/2009/01/uitableview-creating-simple-table-view.html –

回答

1

你只需要創建一個實現UITableViewDataSource的對象。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return [self.yourArray count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    /* create your cell here */ 

    AnObjectFromYourArray *myObject = [self.yourArray objectAtIndex:[indexPath row]; 

    /* fill the cell with the info in my object */ 

    return yourCell; 
} 

那麼簡單。

格雷格