0

ゲーム開始前に指示を表示するアラートを追加するにはどうすればよいですか:

以下のコードを参照してください。

- (void)viewDidLoad
{
    [super viewDidLoad];
    if (questions && configDictionary) {

        [questionLabel setText:[[questions objectAtIndex:currentQuestonIndex] objectForKey:@"question"]];
        NSArray *answers = [[questions objectAtIndex:currentQuestonIndex] objectForKey:@"answers"];
        [answerLabel0 setText:[answers objectAtIndex:0]];
        [answerLabel1 setText:[answers objectAtIndex:1]];
        [answerLabel2 setText:[answers objectAtIndex:2]];
        [answerLabel3 setText:[answers objectAtIndex:3]];
        [pointsPerAnswerLabel setText:[NSString stringWithFormat:@"+%d points", [[configDictionary objectForKey:kPointsPerCorrectAnswer] intValue]]];
        [currentQuestionNumberLabel setText:[NSString stringWithFormat:@"question %d", currentQuestonIndex+1]];
    }
}
4

2 に答える 2

0

Use a UIAlertView:

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Instructions" 
    message:@"Your Instructions..." delegate:self cancelButtonTitle:@"Dismiss" 
    otherButtonTitles:nil, nil]; 

    [alert show];

If you want to alert the user every time the app launches place it in the

 - (void)applicationDidFinishLaunching:(UIApplication *)application {
    }

Edit

You said you wanted to start the game after the dismiss button is pressed. So take advantage of the UIAlertView delegate:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {

    if (buttonIndex == 0){

        //Start your game!

    }

}
于 2012-08-09T19:52:25.050 に答える
0
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"How to play"
                                                  message:@"Answer the questions correctly to get points blablabla..."
                                                 delegate:nil
                                        cancelButtonTitle:@"OK"
                                        otherButtonTitles:nil];
[message show];
于 2012-08-09T19:52:53.033 に答える