- 我正在尝试使用情节提要在视图控制器中显示问题,并且当用户单击显示答案时。它将它从视图
控制器带到另一个。另一个视图控制器只显示
答案并有一个后退按钮。 - 两个视图控制器使用相同的
类。用户可以根据问题在应用程序中将下一个和上一个字符串从一个字符串切换到
另一个字符串。 - 当我在第一个问题上单击显示答案时,我
可以看到答案数组中的第一个字符串说大声笑,但是当我进入下一个
问题并单击显示答案时,它说的答案相同。 - 我链接了 ib 动作 showanswer,但它似乎没有任何效果。Show Answer 按钮通过 segue 转到另一个视图控制器
,并且还有 ib 动作 show answer 链接到它。
所以我的问题是我在 ib 动作 showAnswer 中做错了什么?如果我错误地接近这个抽认卡类型的应用程序,我做错了什么?
//
// BiologyViewController.m
// Biology
//
// Created by Jacob Brans on 6/6/13.
// Copyright (c) 2013 Jacob Brans. All rights reserved.
//
#import "BiologyViewController.h"
@interface BiologyViewController ()
@end
@implementation BiologyViewController
@synthesize labelsText;
@synthesize textView, textViewanswer1;
-(void)viewDidLoad {
[super viewDidLoad];
titles = [NSArray arrayWithObjects:// Time Together
@"What is Biology?",@"What is yo mamma?",nil];
step= 0;
textView.text = [titles objectAtIndex:step];
answers = [NSArray arrayWithObjects:// Time Together
@"lol",@"wow",nil];
textViewanswer1.text = [answers objectAtIndex:step];
labelsText.text = [NSString stringWithFormat:@"%d/%d", step+1, titles.count];
}
-(IBAction)showanswer:(id)sender{
textViewanswer1.text = [answers objectAtIndex:step];
}
-(IBAction) nextclicked:(id)sender{
// titles = [NSArray arrayWithObjects:@"iology is the scientific study of life. Bam",@"This works? Wow",@"lol", nil];
if (step<titles.count-1) {
step++;
}
else
{
step= 0;
}
textView.text = [titles objectAtIndex:step];
labelsText.text = [NSString stringWithFormat:@"%d/%d", step+1, titles.count];
}
-(IBAction) prevClicked:(id)sender{
// titles = [NSArray arrayWithObjects:@"Biology is the scientific study of life. Bam",@"This works? Wow",@"Still Works.",@"garret is the coolest awesome person awesome wowowowwwwwwwwwwwwwwwwwwwwwwwwwww", nil];
if (step>0) {
step--;
}
else
{
step =titles.count-1;
}
textView.text = [titles objectAtIndex:step];
labelsText.text = [NSString stringWithFormat:@"%d/%d", step+1, titles.count];
}
-(IBAction) randomClicked:(id)sender{
step = 1+arc4random() %(titles.count);
textView.text = [titles objectAtIndex:step];
labelsText.text = [NSString stringWithFormat:@"%d/%d", step+1, titles.count];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end