Marino Faggiana 8 years ago
parent
commit
be40f825b3
1 changed files with 21 additions and 23 deletions
  1. 21 23
      iOSClient/Main/CCMain.m

+ 21 - 23
iOSClient/Main/CCMain.m

@@ -512,18 +512,6 @@
     return ([[[alertView textFieldAtIndex:0] text] length]>0)?YES:NO;
     return ([[[alertView textFieldAtIndex:0] text] length]>0)?YES:NO;
 }
 }
 
 
-- (void)alertTextFieldDidChange:(UITextField *)sender
-{
-    UIAlertController *alertController = (UIAlertController *)self.presentedViewController;
-    
-    if (alertController)
-    {
-        UITextField *fileName = alertController.textFields.firstObject;
-        UIAlertAction *okAction = alertController.actions.lastObject;
-        okAction.enabled = fileName.text.length > 0;
-    }
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Graphic Window =====
 #pragma mark ===== Graphic Window =====
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------
@@ -4149,6 +4137,23 @@
     }
     }
 }
 }
 
 
+#pragma mark -
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark ===== Text Field DidChange =====
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)renameFileNameTextFieldDidChange:(UITextField *)sender
+{
+    UIAlertController *alertController = (UIAlertController *)self.presentedViewController;
+    
+    if (alertController)
+    {
+        UITextField *fileName = alertController.textFields.firstObject;
+        UIAlertAction *okAction = alertController.actions.lastObject;
+        okAction.enabled = fileName.text.length > 0;
+    }
+}
+
 #pragma mark -
 #pragma mark -
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Swipe Tablet -> menu =====
 #pragma mark ===== Swipe Tablet -> menu =====
@@ -4283,20 +4288,11 @@
                                         // close swipe
                                         // close swipe
                                         [self setEditing:NO animated:YES];
                                         [self setEditing:NO animated:YES];
                                         
                                         
-                                        /*
-                                        //chiediamo il nome del file
-                                        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"_rename_",nil) message:nil delegate:self cancelButtonTitle:NSLocalizedString(@"_cancel_",nil) otherButtonTitles:NSLocalizedString(@"_save_", nil), nil];
-                                        [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
-                                        alertView.tag = alertRename;
-                                        UITextField *textField = [alertView textFieldAtIndex:0];
-                                        textField.text = _metadata.fileNamePrint;
-                                        [alertView show];
-                                        */
-                                        
                                         UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_rename_",nil) message:nil preferredStyle:UIAlertControllerStyleAlert];
                                         UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_rename_",nil) message:nil preferredStyle:UIAlertControllerStyleAlert];
                                         
                                         
                                         [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
                                         [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
-                                             textField.placeholder = _metadata.fileNamePrint;
+                                            textField.placeholder = _metadata.fileNamePrint;
+                                            [textField addTarget:self action:@selector(renameFileNameTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
                                         }];
                                         }];
                                         
                                         
                                         UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                                         UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
@@ -4314,6 +4310,8 @@
 
 
                                         [alertController addAction:cancelAction];
                                         [alertController addAction:cancelAction];
                                         [alertController addAction:okAction];
                                         [alertController addAction:okAction];
+                                        
+                                        [self presentViewController:alertController animated:YES completion:nil];
                                     }];
                                     }];
         }
         }