comparison QuestionnaireViewController.mm @ 28:e2c62db1e265

Started timer stuff
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 18 Feb 2013 11:45:05 +0000
parents ae4d2c3ce5e0
children fabb3a5cdfc9
comparison
equal deleted inserted replaced
27:ae4d2c3ce5e0 28:e2c62db1e265
58 58
59 // load question 1 59 // load question 1
60 [self loadQuestion:self.currentQuestionIndex]; 60 [self loadQuestion:self.currentQuestionIndex];
61 61
62 self.previousButton.hidden = YES; // dont bother 62 self.previousButton.hidden = YES; // dont bother
63 63 self.commentText.hidden = YES;
64 self.finishButton.hidden = YES;
64 } 65 }
65 //---------------------------------------------------------------- 66 //----------------------------------------------------------------
66 - (void)didReceiveMemoryWarning 67 - (void)didReceiveMemoryWarning
67 { 68 {
68 [super didReceiveMemoryWarning]; 69 [super didReceiveMemoryWarning];
74 [_questionText release]; 75 [_questionText release];
75 [_titleText release]; 76 [_titleText release];
76 [_finishButton release]; 77 [_finishButton release];
77 [_nextButton release]; 78 [_nextButton release];
78 [_previousButton release]; 79 [_previousButton release];
80 [_commentText release];
79 [super dealloc]; 81 [super dealloc];
80 } 82 }
81 //---------------------------------------------------------------- 83 //----------------------------------------------------------------
82 - (void)viewDidUnload { 84 - (void)viewDidUnload {
83 [self setQuestionText:nil]; 85 [self setQuestionText:nil];
84 [self setTitleText:nil]; 86 [self setTitleText:nil];
85 [self setFinishButton:nil]; 87 [self setFinishButton:nil];
86 [self setNextButton:nil]; 88 [self setNextButton:nil];
87 [self setPreviousButton:nil]; 89 [self setPreviousButton:nil];
90 [self setCommentText:nil];
88 [super viewDidUnload]; 91 [super viewDidUnload];
89 } 92 }
90 //---------------------------------------------------------------- 93 //----------------------------------------------------------------
91 -(IBAction)hide:(id)sender{ 94 -(IBAction)hide:(id)sender{
92 // called when finish button hit 95 // called when finish button hit
99 for(int i=0;i<[questionArray count];i++){ 102 for(int i=0;i<[questionArray count];i++){
100 q = [questionArray objectAtIndex:i]; 103 q = [questionArray objectAtIndex:i];
101 answersArray.push_back(q.answer); 104 answersArray.push_back(q.answer);
102 105
103 } 106 }
104 107 const char *userComments = [self.commentText.text cStringUsingEncoding: NSUTF8StringEncoding];
105 ((testApp *)self.theOFAppRef)->questionnaireHidden(answersArray); 108
109 ((testApp *)self.theOFAppRef)->questionnaireHidden(answersArray, userComments);
110 [self.commentText resignFirstResponder];
111
106 self.view.hidden = YES; 112 self.view.hidden = YES;
107 } 113 }
114
108 //---------------------------------------------------------------- 115 //----------------------------------------------------------------
109 -(IBAction)show:(id)sender{ 116 -(IBAction)show:(id)sender{
110 self.view.hidden = NO; 117 self.view.hidden = NO;
111 } 118 }
112 //---------------------------------------------------------------- 119 //----------------------------------------------------------------
141 // hide next question button 148 // hide next question button
142 self.nextButton.hidden = YES; 149 self.nextButton.hidden = YES;
143 // hide selector 150 // hide selector
144 self.picker.hidden = YES; 151 self.picker.hidden = YES;
145 self.previousButton.hidden = YES; 152 self.previousButton.hidden = YES;
153 self.finishButton.hidden = NO;
146 154
147 self.titleText.text = @"Thank you!"; 155 self.titleText.text = @"Thank you!";
148 156
149 self.questionText.text = @"Thanks for helping science help you. Visit the study website to keep abreast of exciting events."; 157 self.commentText.hidden = NO;
158
159 self.questionText.text = @"Thanks for helping science help you. Feel free to add further comments in the text box below, and then press 'finish' to go back to the app.";
150 } 160 }
151 161
152 //---------------------------------------------------------------- 162 //----------------------------------------------------------------
153 - (void)loadQuestion:(NSInteger)questionIndex { 163 - (void)loadQuestion:(NSInteger)questionIndex {
154 // populate text fields with question 164 // populate text fields with question
236 // chek wot we just rote 246 // chek wot we just rote
237 247
238 NSLog(@"Answer: %d",curQ.answer); 248 NSLog(@"Answer: %d",curQ.answer);
239 249
240 } 250 }
241 251 //----------------------------------------------------------------
252 #pragma mark UITextViewDelegate functions
253 /*
254 This answer was useful to me, but I was also looking for the callback function from the "Go" button, which I found is:
255 - (BOOL) textFieldShouldReturn:(UITextField *)textField { // Customer code return YES; }
256
257 You will need to send the UITextField delegate to your view controller for that to work.
258
259 */
260 - (BOOL) textFieldShouldReturn:(UITextField *)textField {
261 // Customer code
262 NSLog(@"RETURN DELEGATE");
263 [self hide:self ];
264 return NO;
265 }
242 @end // end implementation 266 @end // end implementation
243 //---------------------------------------------------------------- 267 //----------------------------------------------------------------
244 //---------------------------------------------------------------- 268 //----------------------------------------------------------------