In Objective C: How to show 3 values on 1 row? [closed]
I have one Player Object Array with player Name and player Score, I want to show like:
row+1. Player1开发者_运维百科 ____playerScore1
row+1. Player2 ____playerScore2
row+1. Player3 ____playerScore3
.......
Thank you for your help,
Harry.
Checkout UITableView:
http://www.littlecomputers.net/2009/?page_id=549
http://www.icodeblog.com/2008/08/08/iphone-programming-tutorial-populating-uitableview-with-an-nsarray/
And also customizing the table view cells:
http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
Hope those helps
edit: I pasted the wrong link in my initial post (one for mono touch - meant to include on for UITableView over array)
Assuming you're talking about a UITable... I'm using this approach in a current project.
Creating a grid view in iOS
It's very straightforward, assuming you know your way around table controllers. The code on the blog post explains how it's put together. For each row, you simply setup the cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
GridTableViewCell *cell = (GridTableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[GridTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.lineColor = [UIColor blackColor];
}
// Since we are drawing the lines ourself, we need to know which cell is the top cell in the table so that
// we can draw the line on the top
if (indexPath.row == 0)
cell.topCell = YES;
else
cell.topCell = NO;
// Configure the cell.
cell.cell1.text = [NSString stringWithFormat:@"%i", indexPath.row];
cell.cell2.text = [NSString stringWithFormat:@"%i", indexPath.row];
cell.cell3.text = @"Sample text";
return cell;
}
精彩评论