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