私はアプリケーションを作成していますが、次のコードでエラーが発生しました:
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];
}
だから私が直面している問題は次のとおりです。
- ボタンはアラートでは機能しません。単に何もしません。
- 「単項式への無効な引数タイプ "void"」というエラーがあります
どうすればこれを解決できますか?