Browse Source

PDFForm(iOS) - 下拉与列表不支持创建Item

dinglingui 1 year ago
parent
commit
24b6f0ac5a

+ 21 - 33
ComPDFKit_Tools/ComPDFKit_Tools/Forms/PDFFormProperties/Controller/CPDFFormListOptionVC.m

@@ -197,43 +197,31 @@
 #pragma mark - Action
 
 - (void)buttonItemClicked_add:(id)sender {
-    if (![self.pdfView.document bookmarkForPageIndex:self.pdfView.currentPageIndex]) {
-        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Add Items" message:nil preferredStyle:UIAlertControllerStyleAlert];
-        [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
-            textField.placeholder = NSLocalizedString(@"Input Option", nil);
-        }];
-            
-        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil];
+    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Add Items" message:nil preferredStyle:UIAlertControllerStyleAlert];
+    [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
+        textField.placeholder = NSLocalizedString(@"Input Option", nil);
+    }];
         
-        UIAlertAction *addAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Add", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-            if(alert.textFields.firstObject.text.length > 0) {
+    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil];
+    
+    UIAlertAction *addAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Add", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        if(alert.textFields.firstObject.text.length > 0) {
 
-                CPDFChoiceWidgetItem * widgetItem = [[CPDFChoiceWidgetItem alloc] init];
-                widgetItem.string = widgetItem.value = alert.textFields.firstObject.text;
-                [self.options addObject:widgetItem];
-                CPDFChoiceWidgetAnnotation * mAnnotation = (CPDFChoiceWidgetAnnotation *)self.annotation;
-                mAnnotation.items = self.options;
-                if(!mAnnotation.isListChoice){
-                    mAnnotation.selectItemAtIndex = 0;
-                }
-                [self reloadData];
+            CPDFChoiceWidgetItem * widgetItem = [[CPDFChoiceWidgetItem alloc] init];
+            widgetItem.string = widgetItem.value = alert.textFields.firstObject.text;
+            [self.options addObject:widgetItem];
+            CPDFChoiceWidgetAnnotation * mAnnotation = (CPDFChoiceWidgetAnnotation *)self.annotation;
+            mAnnotation.items = self.options;
+            if(!mAnnotation.isListChoice){
+                mAnnotation.selectItemAtIndex = 0;
             }
-        }];
-        
-        [alert addAction:cancelAction];
-        [alert addAction:addAction];
-        [self presentViewController:alert animated:YES completion:nil];
-    } else {
-        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
-                                                               style:UIAlertActionStyleCancel
-                                                             handler:nil];
-        UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil
-                                                                       message:NSLocalizedString(@"You've createed box list about this", nil)
-                                                                preferredStyle:UIAlertControllerStyleAlert];
-        [alert addAction:cancelAction];
+            [self reloadData];
+        }
+    }];
     
-        [self presentViewController:alert animated:YES completion:nil];
-    }
+    [alert addAction:cancelAction];
+    [alert addAction:addAction];
+    [self presentViewController:alert animated:YES completion:nil];
 }
 
 #pragma mark - UITableViewDataSource