如何在游戏开始前添加显示说明的提醒:
见下面的代码:
- (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]];
}
}
答案 0 :(得分:0)
使用UIAlertView
:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Instructions"
message:@"Your Instructions..." delegate:self cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil, nil];
[alert show];
如果您想在每次应用启动时提醒用户将其置于
中 - (void)applicationDidFinishLaunching:(UIApplication *)application {
}
修改强>
你说你想在按下解除按钮后开始游戏。因此,请利用UIAlertView delegate
:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0){
//Start your game!
}
}
答案 1 :(得分: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];