2011-10-24 96 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; 
} 

那么简单。

格雷格