我正在制作和应用,并且遇到了以下代码的错误:
NSString *timemessage = [NSString stringWithFormat:@"Unlucky! You survived for %i seconds!", timenumber];
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"You've Been Caught!" message:timemessage delegate:nil cancelButtonTitle:@"Try Again" otherButtonTitles:@"Show Leaderboard", @"Submit To Game Center",nil];
[alert1 show];
-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)ButtonIndex {
NSString *buttonTitle = [alertView buttonTitleAtIndex:ButtonIndex];
if ([buttonTitle isEqualToString:@"Submit To Game Center"]) {
- (void) reportScore: (int64_t) score forCategory: (NSString*) category
{
GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:@"*****"] autorelease];
scoreReporter.value = score;
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil)
{
// handle the reporting error
}
}];
}
}
else if ([buttonTitle isEqualToString:@"Show Leaderboard"]){
- (void) showLeaderboard:
{
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != nil)
{
leaderboardController.leaderboardDelegate = self;
[self presentModalViewController: leaderboardController animated: YES];
}
}
}
}
-(void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController{
[self dismissModalViewControllerAnimated:YES];
}
所以我面临的问题是:
我该如何解决这个问题?
答案 0 :(得分:0)
我确信第一个问题出在警报代表身上。
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"You've Been Caught!" message:timemessage delegate:self cancelButtonTitle:@"Try Again" otherButtonTitles:@"Show Leaderboard", @"Submit To Game Center",nil];
[alert1 show];
请参阅委托人:自我