我有一个显示随机问题的视图控制器。在这堂课中,我有一个按钮;当您单击此按钮时,它会转到另一个视图并显示正确答案。
我可以显示我的随机问题,但如何在另一个视图中设置我的正确答案?(基于我的问题)
我的随机问题代码是:
{
NSString *one = @"Question 1?";
NSString *two = @"Question 2?";
NSString *three = @"Question 3?";
NSString *four = @"Question 4?";
NSString *five = @"Question 5?";
NSString *six = @"Question 6?";
NSArray *answerComments = [[NSArray alloc] initWithObjects:one, two, three, four, five, six, nil];
int rand = arc4random()%6;
NSString *answer = [answerComments objectAtIndex:rand];
[question setText:(answer)];
[question setFrame:CGRectMake(50, 295, 200, 80)];
question.adjustsFontSizeToFitWidth = NO;
question.numberOfLines = 0;
}
- (IBAction)answer:(id)sender {
AnswerViewController *b = [[AnswerViewController alloc] init];
[self.navigationController pushViewController:b animated:YES];
}
在我的下一个视图中,显示了我的正确答案UILabel *correctAnswer
NSString *one = @"answer 1";
NSString *two = @"answer 2";
NSString *three = @"answer 3";
NSString *four = @"answer 4";
NSString *five = @"answer 5";
NSString *six = @"answer 6";