Mercurial > hg > soniczoomios
annotate UsernameAlertViewController.mm @ 25:f42a00e3f22d
Logs condensed slightly. Questionnaire button enable.
double precision location!!!
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Fri, 01 Feb 2013 17:39:19 +0000 |
parents | fb2ef16dd013 |
children | 23ef179c3748 |
rev | line source |
---|---|
rt300@16 | 1 // |
rt300@16 | 2 // iViewController.m |
rt300@16 | 3 // oscSenderExample |
rt300@16 | 4 // |
rt300@16 | 5 // Created by Robert Tubb on 07/01/2013. |
rt300@16 | 6 // |
rt300@16 | 7 // |
rt300@16 | 8 #include "eventLogger.h" |
rt300@16 | 9 |
rt300@16 | 10 #import "usernameAlertViewController.h" |
rt300@16 | 11 |
rt300@16 | 12 |
rt300@16 | 13 extern EventLogger eventLogger; |
rt300@16 | 14 |
rt300@16 | 15 @implementation UsernameAlertViewController |
rt300@16 | 16 |
rt300@16 | 17 -(void)showUserNamePrompt{ |
rt300@16 | 18 |
rt300@16 | 19 |
rt300@16 | 20 UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Hello!" |
rt300@16 | 21 message:@"Please enter your name:" |
rt300@16 | 22 delegate:self |
rt300@16 | 23 cancelButtonTitle:@"Continue" |
rt300@16 | 24 otherButtonTitles:nil]; |
rt300@16 | 25 alert.alertViewStyle = UIAlertViewStylePlainTextInput; |
rt300@16 | 26 UITextField * alertTextField = [alert textFieldAtIndex:0]; |
rt300@16 | 27 alertTextField.keyboardType = UIKeyboardTypeDefault; |
rt300@16 | 28 alertTextField.placeholder = @"Username"; |
rt300@16 | 29 [alert show]; |
rt300@16 | 30 [alert release]; |
rt300@16 | 31 |
rt300@16 | 32 |
rt300@16 | 33 } |
rt300@16 | 34 |
rt300@16 | 35 |
rt300@16 | 36 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ |
rt300@16 | 37 |
rt300@16 | 38 NSLog(@"Entered: %@",[[alertView textFieldAtIndex:0] text]); |
rt300@16 | 39 NSString *userName = [[alertView textFieldAtIndex:0] text]; |
rt300@16 | 40 if ([userName isEqualToString:@""]){ |
rt300@16 | 41 [self showUserNamePrompt]; |
rt300@16 | 42 return; |
rt300@16 | 43 } |
rt300@16 | 44 eventLogger.setUsername([userName cStringUsingEncoding:NSASCIIStringEncoding]); |
rt300@16 | 45 |
rt300@16 | 46 |
rt300@16 | 47 } |
rt300@16 | 48 |
rt300@16 | 49 |
rt300@16 | 50 - (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView |
rt300@16 | 51 { |
rt300@16 | 52 UITextField *textField = [alertView textFieldAtIndex:0]; |
rt300@16 | 53 if ([textField.text length] == 0) |
rt300@16 | 54 { |
rt300@16 | 55 return NO; |
rt300@16 | 56 } |
rt300@16 | 57 return YES; |
rt300@16 | 58 } |
rt300@16 | 59 |
rt300@16 | 60 |
rt300@16 | 61 @end |
rt300@16 | 62 |
rt300@16 | 63 |
rt300@16 | 64 // global. again. |
rt300@25 | 65 |