我正在设计一个老虎机项目,它对高分页面有第二个视图。在大多数情况下,除了获胜者从老虎机传递到高分页面之外,一切正常。这是我在老虎机方法中的代码:
if(win == YES) {
NSString *msg = nil;
if(playerField.text.length > 0) {
msg = [[NSString alloc] initWithFormat:@"%@", playerField.text];
}
NSLog(@"DEBUG");
[(HighScorePage *)self.view addNewHighScore:msg];
[self performSelector:@selector(playWinSound) withObject:nil afterDelay:.5];
[msg release];
}
这是 HighScorePage 中的 addNewHighScore 方法:
-(void)addNewHighScore:(NSString *)player {
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
int i = 0;
for (NSArray *count in dynPlayerArray) {
[tempArray addObject:[NSIndexPath indexPathForRow:i++ inSection:0]];
}
[tempArray addObject:player];
[[self highScores] beginUpdates];
[[self highScores] insertRowsAtIndexPaths:(NSArray *)tempArray withRowAnimation:UITableViewRowAnimationNone];
[[self highScores] endUpdates];
[tempArray release];
}
在这方面还是新手,所以让我知道你的想法!谢谢!