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