comparison PresetAlertViewController.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 650589cac373
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 "presetManager.h"
9
10 #import "PresetAlertViewController.h"
11
12
13 extern PresetManager presetManager;
14 @implementation PresetAlertViewController
15
16 - (void)showPresetNamePrompt{
17 UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Save"
18 message:@"Enter preset name:"
19 delegate:self
20 cancelButtonTitle:@"Cancel"
21 otherButtonTitles:@"Enter",nil];
22 alert.alertViewStyle = UIAlertViewStylePlainTextInput;
23 UITextField * alertTextField = [alert textFieldAtIndex:0];
24 alertTextField.keyboardType = UIKeyboardTypeDefault;
25 alertTextField.placeholder = @"Preset Name";
26 [alert show];
27 [alert release];
28 }
29
30 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
31
32 NSLog(@"Preset save ");
33 if(buttonIndex == 0){
34 // cancel
35 NSLog(@"preset save was cancelled");
36 }else{
37 // save it
38 presetManager.addPreset([[[alertView textFieldAtIndex:0] text] cStringUsingEncoding:NSASCIIStringEncoding]);
39 }
40 }
41
42
43 - (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView
44 {
45 UITextField *textField = [alertView textFieldAtIndex:0];
46 if ([textField.text length] == 0)
47 {
48 return NO;
49 }
50 return YES;
51 }
52
53
54 @end
55
56
57 // global? again.
58 PresetAlertViewController *presetAlertViewController = [[PresetAlertViewController alloc] init];