- Я пытаюсь отобразить вопросы в контроллере представления, используя раскадровки, и когда пользователь нажимает, показывает ответ. Он переносит его из контроллера view
в другой. Другой контроллер представления просто показывает
ответ и имеет кнопку "Назад". - Оба контроллера представления используют один и тот же класс
. Пользователь может переключать следующее и предыдущее из одной строки
в другую в приложении из вопроса. - Когда я нажимаю «Показать ответ на первый вопрос», я
вижу первую строку в массиве ответов, которая говорит «смеется», но когда я перехожу к следующему
вопросу и нажимаю «Показать ответ», он говорит тот же ответ. - Я связал действие ib showanswer, но, похоже, это не дало никакого эффекта. Кнопка «Показать ответ» переходит к другому контроллеру представления
через переход, а также имеет связанный с ней ответ ib action show.
Итак, мой вопрос: что я делаю неправильно в ib action 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
step
(свойство, статическая переменная)?? - person Roshan   schedule 07.06.2013