Objective c 如何使用NSMutableArray填充rootviewcontroller表视图
我正试图用NSMutableArray填充tableview,但我真的很难使用它 我想这应该很简单,但我不能让它工作 任何帮助都将不胜感激Objective c 如何使用NSMutableArray填充rootviewcontroller表视图,objective-c,ios,uitableview,nsmutablearray,Objective C,Ios,Uitableview,Nsmutablearray,我正试图用NSMutableArray填充tableview,但我真的很难使用它 我想这应该很简单,但我不能让它工作 任何帮助都将不胜感激 谢谢您只需创建一个实现UITableViewDataSource的对象 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.yourArray count]; } - (UITableViewC
谢谢您只需创建一个实现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;
}
就这么简单
Greg您只需创建一个实现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;
}
就这么简单
Greg网上有很多教程,甚至有关于创建简单表视图的StackOverflow教程。你应该四处搜索一下!这是谷歌的第一个成功案例:网络上有很多教程,甚至还有创建简单表视图的StackOverflow。你应该四处搜索一下!以下是谷歌的第一个成功案例: