你可以这样做。该方法是获取显示正在进行的游戏的 UITableView 所需的所有数据。在这里展示一个完全自定义的基于回合的游戏中心视图的代码会很长。如果您查看为表格截取的代码,也许您会了解这个概念:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MatchCell" owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
}
GKTurnBasedMatch *match = [[allMyMatches objectAtIndex:indexPath.section ] objectAtIndex:indexPath.row];
MatchCell *c = (MatchCell *)cell;
c.match = match;
c.delegate = self;
if ([match.matchData length] > 0) {
NSString *storyString = [NSString stringWithUTF8String:[match.matchData bytes]];
c.storyText.text = storyString;
int days = -floor([match.creationDate timeIntervalSinceNow] / (60 * 60 * 24));
c.statusLabel.text = [NSString stringWithFormat:@"Story started %d days ago and is about %d words", days, [storyString length] / 5];
}
if (indexPath.section == 2) {
[c.quitButton setTitle:@"Remove" forState:UIControlStateNormal];
[c.quitButton setTitle:@"Remove" forState:UIControlStateNormal];
}
return cell;
}
关于该主题的完整教程在 iOS 5 中,来自 Ray Wenderlich 的教程团队的 Tutorials。如果您觉得大方,请点击以下链接:http ://www.raywenderlich.com/store/ios-5-by-tutorials