فهرست منبع

PDFTools(iOS) - page edit bug修改

yangliuhua 1 سال پیش
والد
کامیت
38c0bada2d
17فایلهای تغییر یافته به همراه225 افزوده شده و 111 حذف شده
  1. 1 1
      ComPDFKit/ComPDFKit/CPDFViewController.m
  2. 8 17
      Edit-Ctrl-Demo/Edit-Ctrl-Demo/CPDFViewController.m
  3. 2 2
      Form-Ctrl-Demo/Form-Ctrl-Demo.xcodeproj/project.pbxproj
  4. 7 1
      PageEdit-Ctrl-Demo/PageEdit-Ctrl-Demo/CPDFViewController.m
  5. 1 1
      compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFStamp/CPDFStampViewController.m
  6. 10 7
      compdfkit-tools/compdfkit-tools/Common/Controls/PDFViewController/CPDFViewBaseController.m
  7. 23 12
      compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormButtonViewController.m
  8. 22 14
      compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormCheckBoxViewController.m
  9. 22 14
      compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormComboxViewController.m
  10. 10 2
      compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormListOptionVC.m
  11. 24 13
      compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormListViewController.m
  12. 22 11
      compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormRadioButtonViewController.m
  13. 22 11
      compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormTextViewController.m
  14. 1 2
      compdfkit-tools/compdfkit-tools/Form/View/CPDFFontSettingView.m
  15. 11 2
      compdfkit-tools/compdfkit-tools/PageEdit/Control/CPDFPageEditViewController.m
  16. 7 1
      compdfkit-tools/compdfkit-tools/PageEdit/Views/CPDFPageEditViewCell.h
  17. 32 0
      compdfkit-tools/compdfkit-tools/PageEdit/Views/CPDFPageEditViewCell.m

+ 1 - 1
ComPDFKit/ComPDFKit/CPDFViewController.m

@@ -289,7 +289,7 @@
 
 }
 
--(void) enterFormMode {
+- (void)enterFormMode {
     self.toolBar.hidden = YES;
     self.annotationBar.hidden = YES;
     self.formBar.hidden = NO;

+ 8 - 17
Edit-Ctrl-Demo/Edit-Ctrl-Demo/CPDFViewController.m

@@ -149,15 +149,6 @@
     }
 }
 
-- (void)enterPDFShare  {
-    if(self.pdfListView.isEditing && self.pdfListView.isEdited) {
-        [self.pdfListView commitEditing];
-        [self.pdfListView endOfEditing];
-    }
-    
-    [super enterPDFShare];
-}
-
 - (void)enterPDFAddFile  {
     if(self.pdfListView.isEditing && self.pdfListView.isEdited) {
         [self.pdfListView commitEditing];
@@ -174,14 +165,14 @@
     }
 }
 
-- (void)shareRefresh {
-    CPDFEditingConfig *editingConfig = [[CPDFEditingConfig alloc]init];
-    editingConfig.editingBorderWidth = 1.0;
-    editingConfig.editingOffsetGap = 5;
-    self.pdfListView.editingConfig = editingConfig;
-
-    self.pdfListView.toolModel = CToolModelEdit;
-}
+//- (void)shareRefresh {
+//    CPDFEditingConfig *editingConfig = [[CPDFEditingConfig alloc]init];
+//    editingConfig.editingBorderWidth = 1.0;
+//    editingConfig.editingOffsetGap = 5;
+//    self.pdfListView.editingConfig = editingConfig;
+//
+//    self.pdfListView.toolModel = CToolModelEdit;
+//}
 
 
 #pragma mark - CPDFViewDelegate

+ 2 - 2
Form-Ctrl-Demo/Form-Ctrl-Demo.xcodeproj/project.pbxproj

@@ -381,7 +381,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = 1;
-				DEVELOPMENT_TEAM = 4GGQPGRTSV;
+				DEVELOPMENT_TEAM = Q43DRF894U;
 				ENABLE_BITCODE = NO;
 				"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
 				GENERATE_INFOPLIST_FILE = YES;
@@ -410,7 +410,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = 1;
-				DEVELOPMENT_TEAM = 4GGQPGRTSV;
+				DEVELOPMENT_TEAM = Q43DRF894U;
 				ENABLE_BITCODE = NO;
 				"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
 				GENERATE_INFOPLIST_FILE = YES;

+ 7 - 1
PageEdit-Ctrl-Demo/PageEdit-Ctrl-Demo/CPDFViewController.m

@@ -61,7 +61,6 @@
     pageEditViewcontroller.pageEditDelegate = self;
     pageEditViewcontroller.modalPresentationStyle = UIModalPresentationFullScreen;
     [self.navigationController presentViewController:pageEditViewcontroller animated:YES completion:nil];
-//    [self.navigationController pushViewController:pageEditViewcontroller animated:NO];
 }
 
 - (void)titleButtonClickd:(id)sender {
@@ -80,6 +79,13 @@
 }
 
 - (void)pageEditViewController:(CPDFPageEditViewController *)pageEditViewController pageIndex:(NSInteger)pageIndex {
+    __weak typeof(self) weakSelf = self;
+    [weakSelf reloadDocumentWithFilePath:self.filePath password:nil completion:^(BOOL result) {
+        [weakSelf.pdfListView reloadInputViews];
+    }];
+    
+    [weakSelf.pdfListView reloadInputViews];
+    
     [self.pdfListView goToPageIndex:pageIndex animated:NO];
     [self.navigationController popViewControllerAnimated:YES];
 }

+ 1 - 1
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFStamp/CPDFStampViewController.m

@@ -131,7 +131,7 @@ PDFAnnotationStampKey const PDFAnnotationStampKeyShape = @"PDFAnnotationStampKey
         }
         [array addObject:tPicName];
     }
-    [array addObjectsFromArray:@[@"CPDFStampImage-13", @"CPDFStampImage-14", @"CPDFStampImage-15", @"CPDFStampImage-16", @"CPDFStampImage-18", @"CPDFStampImage-20", @"CPDFStampImage_chick", @"CPDFStampImage_cross", @"CPDFStampImage_circle"]];
+    [array addObjectsFromArray:@[@"CPDFStampImage-13", @"CPDFStampImage-14", @"CPDFStampImage-15", @"CPDFStampImage-16", @"CPDFStampImage-20", @"CPDFStampImage-18", @"CPDFStampImage_chick", @"CPDFStampImage_cross", @"CPDFStampImage_circle"]];
     self.standardArray = array;
     self.imgDicCache = [NSMutableDictionary dictionary];
     

+ 10 - 7
compdfkit-tools/compdfkit-tools/Common/Controls/PDFViewController/CPDFViewBaseController.m

@@ -155,20 +155,23 @@
 - (void)enterPDFShare  {
     [self.popMenu hideMenu];
     
-    if (self.pdfListView.isEdited) {
+    if (self.pdfListView.isEditing && self.pdfListView.isEdited) {
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
             [self.pdfListView commitEditing];
             dispatch_async(dispatch_get_main_queue(), ^{
-                [self.pdfListView endOfEditing];
+//                [self.pdfListView endOfEditing];
             });
         });
     } else {
-        [self.pdfListView endOfEditing];
+//        [self.pdfListView endOfEditing];
     }
     
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        NSString *documentFolder = [NSHomeDirectory() stringByAppendingFormat:@"/%@/%@", @"Documents", self.pdfListView.document.documentURL.lastPathComponent];
+        NSURL *url = [NSURL fileURLWithPath:documentFolder];
+        
         if(self.pdfListView.document.isModified) {
-            [self.pdfListView.document writeToURL:self.pdfListView.document.documentURL];
+            [self.pdfListView.document writeToURL:url];
         }
         dispatch_async(dispatch_get_main_queue(), ^{
             [self shareAction];
@@ -487,7 +490,9 @@
 }
 
 - (void)shareAction {
-    UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:@[self.pdfListView.document.documentURL] applicationActivities:nil];
+    NSString *documentFolder = [NSHomeDirectory() stringByAppendingFormat:@"/%@/%@", @"Documents", self.pdfListView.document.documentURL.lastPathComponent];
+    NSURL *url = [NSURL fileURLWithPath:documentFolder];
+    UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:@[url] applicationActivities:nil];
         activityVC.definesPresentationContext = YES;
         if (UIUserInterfaceIdiomPad == UI_USER_INTERFACE_IDIOM()) {
             activityVC.popoverPresentationController.sourceView = self.rightView;
@@ -501,8 +506,6 @@
             } else {
                 NSLog(@"Failed Or Canceled!");
             }
-            
-            [self shareRefresh];
         };
 }
 

+ 23 - 12
compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormButtonViewController.m

@@ -109,14 +109,6 @@
     self.buttonTextFiledView.delegate = self;
     [self.scrcollView addSubview:self.buttonTextFiledView];
     
-//    self.hideFormView = [[CPDFFormSwitchView alloc] init];
-//    self.hideFormView.delegate = self;
-//    self.hideFormView.titleLabel.font = [UIFont boldSystemFontOfSize:13.0];
-//    self.hideFormView.titleLabel.textColor = [UIColor colorWithRed:153/255. green:153/255. blue:153/255. alpha:1];
-//    self.hideFormView.titleLabel.text = NSLocalizedString(@"Hide The Field", nil);
-//    [self.scrcollView addSubview:self.hideFormView];
-//    self.hideFormView.delegate = self;
-    
     self.fontSettingView = [[CPDFFontSettingView alloc] init];
     self.fontSettingView.fontNameLabel.font = [UIFont boldSystemFontOfSize:13.0];
     self.fontSettingView.fontNameLabel.textColor = [UIColor colorWithRed:153/255. green:153/255. blue:153/255. alpha:1];
@@ -262,7 +254,18 @@
 }
 
 - (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection {
-    self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 350 : 660);
+    if ([self.colorPicker superview]) {
+        UIDevice *currentDevice = [UIDevice currentDevice];
+        if (currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+            // This is an iPad
+            self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, 520);
+        } else {
+            // This is an iPhone or iPod touch
+            self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, 320);
+        }
+    } else {
+        self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 350 : 660);
+    }
 }
 
 - (void)viewWillLayoutSubviews {
@@ -289,7 +292,7 @@
         self.textFiledView.frame = CGRectMake(0, 8, self.view.bounds.size.width, 60);
         self.buttonTextFiledView.frame = CGRectMake(0,CGRectGetMaxY(self.textFiledView.frame)+8, self.view.frame.size.width, 60);
         self.borderColorView.frame = CGRectMake(0,CGRectGetMaxY(self.buttonTextFiledView.frame)+8, self.view.frame.size.width, 74);
-        self.backGroundColorView.frame = CGRectMake(0,CGRectGetMaxY(self.textFiledView.frame)+8, self.view.frame.size.width, 74);
+        self.backGroundColorView.frame = CGRectMake(0,CGRectGetMaxY(self.borderColorView.frame)+8, self.view.frame.size.width, 74);
         self.textColorView.frame = CGRectMake(0,CGRectGetMaxY(self.backGroundColorView.frame)+8, self.view.frame.size.width, 74);
         self.fontSettingView.frame = CGRectMake(0, CGRectGetMaxY(self.textColorView.frame)+8, self.view.frame.size.width, 30);
         
@@ -332,11 +335,18 @@
         picker.delegate = self;
         [self presentViewController:picker animated:YES completion:nil];
     } else {
-        self.colorPicker = [[CPDFColorPickerView alloc] initWithFrame:self.view.frame];
+        UIDevice *currentDevice = [UIDevice currentDevice];
+        if (currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+            // This is an iPad
+            _colorPicker = [[CPDFColorPickerView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 520)];
+        } else {
+            // This is an iPhone or iPod touch
+            _colorPicker = [[CPDFColorPickerView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 320)];
+        }
         self.colorPicker.delegate = self;
-        self.colorPicker.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
         self.colorPicker.backgroundColor = [CPDFColorUtils CAnnotationPropertyViewControllerBackgoundColor];
         [self.view addSubview:self.colorPicker];
+        [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
     }
     [self refreshUI];
 }
@@ -352,6 +362,7 @@
     }else if(self.currentSelectColorView == self.textColorView) {
         self.buttonWidget.fontColor = color;
     }
+    [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
     [self refreshUI];
 }
 

+ 22 - 14
compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormCheckBoxViewController.m

@@ -97,14 +97,6 @@
     self.selectDefaultSwitchView.titleLabel.text = NSLocalizedString(@"Button is Checked by default", nil);
     self.selectDefaultSwitchView.delegate = self;
     
-//    self.hideFormSwitchView = [[CPDFFormSwitchView alloc] init];
-//    [self.scrcollView addSubview:self.hideFormSwitchView];
-    
-//    self.hideFormSwitchView.titleLabel.font = [UIFont boldSystemFontOfSize:13.0];
-//    self.hideFormSwitchView.titleLabel.textColor = [UIColor colorWithRed:153/255. green:153/255. blue:153/255. alpha:1];
-//    self.hideFormSwitchView.titleLabel.text = NSLocalizedString(@"Hide The Field", nil);
-//    self.hideFormSwitchView.delegate = self;
-    
     self.arrowStyleView = [[CPDFFormArrowStyleView alloc] init];
     [self.scrcollView addSubview:self.arrowStyleView];
     
@@ -191,7 +183,18 @@
 
 
 - (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection {
-    self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 350 : 600);
+    if ([self.colorPicker superview]) {
+        UIDevice *currentDevice = [UIDevice currentDevice];
+        if (currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+            // This is an iPad
+            self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, 520);
+        } else {
+            // This is an iPhone or iPod touch
+            self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, 320);
+        }
+    } else {
+        self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 350 : 600);
+    }
 }
 
 - (void)viewWillLayoutSubviews {
@@ -208,9 +211,6 @@
         self.colorSelectView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.backGroundColorView.frame)+8,self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 74);
         self.arrowStyleView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.colorSelectView.frame)+8,self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 44);
         self.selectDefaultSwitchView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.arrowStyleView.frame)+8, self.view.frame.size.width - self.view.safeAreaInsets.left, 44);
-//        self.hideFormSwitchView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.selectDefaultSwitchView.frame)+8, self.view.frame.size.width - self.view.safeAreaInsets.left, 44);
-
-        
     } else {
         self.formTextFiledView.frame = CGRectMake(0, 8, self.view.bounds.size.width, 60);
         self.borderColorView.frame = CGRectMake(0,CGRectGetMaxY(self.formTextFiledView.frame)+8, self.view.frame.size.width, 74);
@@ -251,11 +251,18 @@
         picker.delegate = self;
         [self presentViewController:picker animated:YES completion:nil];
     } else {
-        self.colorPicker = [[CPDFColorPickerView alloc] initWithFrame:self.view.frame];
+        UIDevice *currentDevice = [UIDevice currentDevice];
+        if (currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+            // This is an iPad
+            _colorPicker = [[CPDFColorPickerView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 520)];
+        } else {
+            // This is an iPhone or iPod touch
+            _colorPicker = [[CPDFColorPickerView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 320)];
+        }
         self.colorPicker.delegate = self;
-        self.colorPicker.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
         self.colorPicker.backgroundColor = [CPDFColorUtils CAnnotationPropertyViewControllerBackgoundColor];
         [self.view addSubview:self.colorPicker];
+        [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
     }
     
     [self refreshUI];
@@ -272,6 +279,7 @@
     }else if(self.currentSelectColorView == self.colorSelectView) {
         self.buttonWidget.fontColor = color;
     }
+    [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
     [self refreshUI];
 }
 

+ 22 - 14
compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormComboxViewController.m

@@ -101,13 +101,6 @@
     self.textFiledView.delegate = self;
     [self.scrcollView addSubview:self.textFiledView];
     
-//    self.hideFormView = [[CPDFFormSwitchView alloc] init];
-//    self.hideFormView.delegate = self;
-//    self.hideFormView.titleLabel.font = [UIFont boldSystemFontOfSize:13.0];
-//    self.hideFormView.titleLabel.textColor = [UIColor colorWithRed:153/255. green:153/255. blue:153/255. alpha:1];
-//    self.hideFormView.titleLabel.text = NSLocalizedString(@"Hide The Field", nil);
-//    [self.scrcollView addSubview:self.hideFormView];
-    
     self.fontSettingView = [[CPDFFontSettingView alloc] init];
     self.fontSettingView.fontNameLabel.font = [UIFont boldSystemFontOfSize:13.0];
     self.fontSettingView.fontNameLabel.textColor = [UIColor colorWithRed:153/255. green:153/255. blue:153/255. alpha:1];
@@ -233,7 +226,18 @@
 }
 
 - (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection {
-    self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 350 : 600);
+    if ([self.colorPicker superview]) {
+        UIDevice *currentDevice = [UIDevice currentDevice];
+        if (currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+            // This is an iPad
+            self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, 520);
+        } else {
+            // This is an iPhone or iPod touch
+            self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, 320);
+        }
+    } else {
+        self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 350 : 600);
+    }
 }
 
 - (void)viewWillLayoutSubviews {
@@ -252,8 +256,6 @@
     
         self.sizeThickNessView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.fontSettingView.frame),self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 82);
         
-//        self.hideFormView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.sizeThickNessView.frame) + 8,self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 44);
-        
     } else {
         self.textFiledView.frame = CGRectMake(0, 8, self.view.bounds.size.width, 60);
         self.borderColorView.frame = CGRectMake(0,CGRectGetMaxY(self.textFiledView.frame)+8, self.view.frame.size.width, 74);
@@ -262,8 +264,6 @@
         self.fontSettingView.frame = CGRectMake(0, CGRectGetMaxY(self.textColorView.frame)+8, self.view.frame.size.width, 30);
         
         self.sizeThickNessView.frame = CGRectMake(0, CGRectGetMaxY(self.fontSettingView.frame), self.view.frame.size.width, 82);
-        
-//        self.hideFormView.frame = CGRectMake(0, CGRectGetMaxY(self.sizeThickNessView.frame) + 8, self.view.frame.size.width, 44);
     }
     
     self.textFiledView.contentField.text = self.comboxChoiceWidget.fieldName;
@@ -300,11 +300,18 @@
         picker.delegate = self;
         [self presentViewController:picker animated:YES completion:nil];
     } else {
-        self.colorPicker = [[CPDFColorPickerView alloc] initWithFrame:self.view.frame];
+        UIDevice *currentDevice = [UIDevice currentDevice];
+        if (currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+            // This is an iPad
+            _colorPicker = [[CPDFColorPickerView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 520)];
+        } else {
+            // This is an iPhone or iPod touch
+            _colorPicker = [[CPDFColorPickerView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 320)];
+        }
         self.colorPicker.delegate = self;
-        self.colorPicker.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
         self.colorPicker.backgroundColor = [CPDFColorUtils CAnnotationPropertyViewControllerBackgoundColor];
         [self.view addSubview:self.colorPicker];
+        [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
     }
     [self refreshUI];
 }
@@ -320,6 +327,7 @@
     }else if(self.currentSelectColorView == self.textColorView) {
         self.comboxChoiceWidget.fontColor = color;
     }
+    [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
     [self refreshUI];
 }
 

+ 10 - 2
compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormListOptionVC.m

@@ -122,13 +122,21 @@
 
 - (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection
 {
+    
     CGFloat width = [UIScreen mainScreen].bounds.size.width;
     CGFloat height = [UIScreen mainScreen].bounds.size.height;
     
     CGFloat mWidth = fmin(width, height);
     CGFloat mHeight = fmax(width, height);
-    self.preferredContentSize = CGSizeMake(self.view.bounds.size.width,traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? mWidth*0.9 : mHeight*0.9);
-
+    
+    UIDevice *currentDevice = [UIDevice currentDevice];
+    if (currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+        // This is an iPad
+        self.preferredContentSize = CGSizeMake(self.view.bounds.size.width,traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? mWidth*0.5 : mHeight*0.6);
+    } else {
+        // This is an iPhone or iPod touch
+        self.preferredContentSize = CGSizeMake(self.view.bounds.size.width,traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? mWidth*0.9 : mHeight*0.9);
+    }
 }
 
 - (void)buttonItemClicked_back:(UIButton *)button {

+ 24 - 13
compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormListViewController.m

@@ -101,13 +101,6 @@
     self.textFiledView.delegate = self;
     [self.scrcollView addSubview:self.textFiledView];
     
-//    self.hideFormView = [[CPDFFormSwitchView alloc] init];
-//    self.hideFormView.delegate = self;
-//    self.hideFormView.titleLabel.font = [UIFont boldSystemFontOfSize:13.0];
-//    self.hideFormView.titleLabel.textColor = [UIColor colorWithRed:153/255. green:153/255. blue:153/255. alpha:1];
-//    self.hideFormView.titleLabel.text = NSLocalizedString(@"Hide The Field", nil);
-//    [self.scrcollView addSubview:self.hideFormView];
-    
     self.fontSettingView = [[CPDFFontSettingView alloc] init];
     self.fontSettingView.fontNameLabel.font = [UIFont boldSystemFontOfSize:13.0];
     self.fontSettingView.fontNameLabel.textColor = [UIColor colorWithRed:153/255. green:153/255. blue:153/255. alpha:1];
@@ -242,7 +235,18 @@
 }
 
 - (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection {
-    self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 350 : 600);
+    if ([self.colorPicker superview]) {
+        UIDevice *currentDevice = [UIDevice currentDevice];
+        if (currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+            // This is an iPad
+            self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, 520);
+        } else {
+            // This is an iPhone or iPod touch
+            self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, 320);
+        }
+    } else {
+        self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 350 : 600);
+    }
 }
 
 - (void)viewWillLayoutSubviews {
@@ -260,9 +264,6 @@
         self.fontSettingView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.textColorView.frame)+8, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 30);
     
         self.sizeThickNessView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.fontSettingView.frame),self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 82);
-//        
-//        self.hideFormView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.sizeThickNessView.frame) + 8,self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 44);
-        
     } else {
         self.textFiledView.frame = CGRectMake(0, 8, self.view.bounds.size.width, 60);
         self.borderColorView.frame = CGRectMake(0,CGRectGetMaxY(self.textFiledView.frame)+8, self.view.frame.size.width, 74);
@@ -302,11 +303,19 @@
         picker.delegate = self;
         [self presentViewController:picker animated:YES completion:nil];
     } else {
-        self.colorPicker = [[CPDFColorPickerView alloc] initWithFrame:self.view.frame];
+        UIDevice *currentDevice = [UIDevice currentDevice];
+        if (currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+            // This is an iPad
+            _colorPicker = [[CPDFColorPickerView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 520)];
+        } else {
+            // This is an iPhone or iPod touch
+            _colorPicker = [[CPDFColorPickerView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 320)];
+        }
         self.colorPicker.delegate = self;
-        self.colorPicker.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
         self.colorPicker.backgroundColor = [CPDFColorUtils CAnnotationPropertyViewControllerBackgoundColor];
         [self.view addSubview:self.colorPicker];
+        [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
+
     }
     [self refreshUI];
 }
@@ -322,6 +331,8 @@
     }else if(self.currentSelectColorView == self.textColorView) {
         self.listChoiceWidget.fontColor = color;
     }
+    [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
+
     [self refreshUI];
 }
 

+ 22 - 11
compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormRadioButtonViewController.m

@@ -96,14 +96,6 @@
     self.selectDefaultSwitchView.titleLabel.text = NSLocalizedString(@"Button is Checked by default", nil);
     self.selectDefaultSwitchView.delegate = self;
     
-//    self.hideFormSwitchView = [[CPDFFormSwitchView alloc] init];
-//    [self.scrcollView addSubview:self.hideFormSwitchView];
-//    
-//    self.hideFormSwitchView.titleLabel.font = [UIFont boldSystemFontOfSize:13.0];
-//    self.hideFormSwitchView.titleLabel.textColor = [UIColor colorWithRed:153/255. green:153/255. blue:153/255. alpha:1];
-//    self.hideFormSwitchView.titleLabel.text = NSLocalizedString(@"Hide The Field", nil);
-//    self.hideFormSwitchView.delegate = self;
-    
     self.arrowStyleView = [[CPDFFormArrowStyleView alloc] init];
     [self.scrcollView addSubview:self.arrowStyleView];
     
@@ -197,7 +189,18 @@
 
 
 - (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection {
-    self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 350 : 600);
+    if ([self.colorPicker superview]) {
+        UIDevice *currentDevice = [UIDevice currentDevice];
+        if (currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+            // This is an iPad
+            self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, 520);
+        } else {
+            // This is an iPhone or iPod touch
+            self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, 320);
+        }
+    } else {
+        self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 350 : 600);
+    }
 }
 
 - (void)viewWillLayoutSubviews {
@@ -255,11 +258,18 @@
         picker.delegate = self;
         [self presentViewController:picker animated:YES completion:nil];
     } else {
-        self.colorPicker = [[CPDFColorPickerView alloc] initWithFrame:self.view.frame];
+        UIDevice *currentDevice = [UIDevice currentDevice];
+        if (currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+            // This is an iPad
+            _colorPicker = [[CPDFColorPickerView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 520)];
+        } else {
+            // This is an iPhone or iPod touch
+            _colorPicker = [[CPDFColorPickerView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 320)];
+        }
         self.colorPicker.delegate = self;
-        self.colorPicker.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
         self.colorPicker.backgroundColor = [CPDFColorUtils CAnnotationPropertyViewControllerBackgoundColor];
         [self.view addSubview:self.colorPicker];
+        [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
     }
     [self refreshUI];
 }
@@ -275,6 +285,7 @@
     }else if(self.currentSelectColorView == self.colorSelectView) {
         self.buttonWidget.fontColor = color;
     }
+    [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
     [self refreshUI];
 }
 

+ 22 - 11
compdfkit-tools/compdfkit-tools/Form/Controller/CPDFFormTextViewController.m

@@ -102,13 +102,6 @@
     self.textFiledView.delegate = self;
     [self.scrcollView addSubview:self.textFiledView];
     
-//    self.hideFormView = [[CPDFFormSwitchView alloc] init];
-//    self.hideFormView.delegate = self;
-//    self.hideFormView.titleLabel.font = [UIFont boldSystemFontOfSize:13.0];
-//    self.hideFormView.titleLabel.textColor = [UIColor colorWithRed:153/255. green:153/255. blue:153/255. alpha:1];
-//    self.hideFormView.titleLabel.text = NSLocalizedString(@"Hide The Field", nil);
-//    [self.scrcollView addSubview:self.hideFormView];
-    
     self.multiLineView = [[CPDFFormSwitchView alloc] init];
     self.multiLineView.delegate = self;
     self.multiLineView.titleLabel.font = [UIFont boldSystemFontOfSize:13.0];
@@ -258,7 +251,18 @@
 }
 
 - (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection {
-    self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 310 : 620);
+    if ([self.colorPicker superview]) {
+        UIDevice *currentDevice = [UIDevice currentDevice];
+        if (currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+            // This is an iPad
+            self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, 520);
+        } else {
+            // This is an iPhone or iPod touch
+            self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, 320);
+        }
+    } else {
+        self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 310 : 620);
+    }
 }
 
 - (void)viewWillLayoutSubviews {
@@ -277,7 +281,6 @@
         self.fontAlignView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.fontSettingView.frame)+8, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 48);
         self.sizeThickNessView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.fontAlignView.frame)+8,self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 82);
         self.inputTextView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.sizeThickNessView.frame)+8, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 120);
-//        self.hideFormView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.inputTextView.frame) + 8,self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 44);
         self.multiLineView.frame = CGRectMake(self.view.safeAreaInsets.left, CGRectGetMaxY(self.inputTextView.frame) + 8,self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 44);
         
     } else {
@@ -327,11 +330,18 @@
         picker.delegate = self;
         [self presentViewController:picker animated:YES completion:nil];
     } else {
-        self.colorPicker = [[CPDFColorPickerView alloc] initWithFrame:self.view.frame];
+        UIDevice *currentDevice = [UIDevice currentDevice];
+        if (currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+            // This is an iPad
+            _colorPicker = [[CPDFColorPickerView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 520)];
+        } else {
+            // This is an iPhone or iPod touch
+            _colorPicker = [[CPDFColorPickerView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, 320)];
+        }
         self.colorPicker.delegate = self;
-        self.colorPicker.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
         self.colorPicker.backgroundColor = [CPDFColorUtils CAnnotationPropertyViewControllerBackgoundColor];
         [self.view addSubview:self.colorPicker];
+        [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
     }
     [self refreshUI];
 }
@@ -347,6 +357,7 @@
     }else if(self.currentSelectColorView == self.textColorView) {
         self.textWidget.fontColor = color;
     }
+    [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
     [self refreshUI];
 }
 

+ 1 - 2
compdfkit-tools/compdfkit-tools/Form/View/CPDFFontSettingView.m

@@ -58,9 +58,8 @@
         
         self.fontNameSelectLabel = [[UILabel alloc] init];
         self.fontNameSelectLabel.adjustsFontSizeToFitWidth = YES;
-        self.fontNameSelectLabel.textColor = [UIColor blackColor];
         [self.dropMenuView addSubview:self.fontNameSelectLabel];
-        self.fontNameSelectLabel.textColor = [CPDFColorUtils CFormFontColor];
+        self.fontNameSelectLabel.textColor = [CPDFColorUtils CPageEditToolbarFontColor];
         
         self.fontSelectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
         self.fontSelectBtn.backgroundColor = [UIColor clearColor];

+ 11 - 2
compdfkit-tools/compdfkit-tools/PageEdit/Control/CPDFPageEditViewController.m

@@ -41,6 +41,10 @@
 
 @property (nonatomic, assign) BOOL isPageEdit;
 
+@property (nonatomic, strong) CPDFPage *currentPage;
+
+@property (nonatomic, assign) NSInteger pageIndex;
+
 @end
 
 @implementation CPDFPageEditViewController
@@ -56,7 +60,6 @@
     self.headerView.backgroundColor = [CPDFColorUtils CAnnotationPropertyViewControllerBackgoundColor];
     [self.view addSubview:self.headerView];
     
-//    [self.titleLabel removeFromSuperview];
     self.titleLabel.text =  NSLocalizedString(@"Page Edit", nil);
     self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 65, 120, 50);
     self.titleLabel.textAlignment = NSTextAlignmentCenter;
@@ -98,6 +101,8 @@
     self.doneBtn.hidden = YES;
     self.selectAllBtn.hidden = YES;
     self.isPageEdit = NO;
+    
+    self.currentPage = [self.pdfView.document pageAtIndex:self.pdfView.currentPageIndex];
 }
 
 - (void)viewWillLayoutSubviews {
@@ -181,7 +186,9 @@
     
     [self.collectionView reloadData];
     
-    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:self.pdfView.currentPageIndex inSection:0];
+    self.pageIndex = [self.pdfView.document indexForPage:self.currentPage];
+    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:self.pageIndex inSection:0];
+
     [self.collectionView selectItemAtIndexPath:indexPath
                                       animated:NO
                                 scrollPosition:UICollectionViewScrollPositionCenteredVertically];
@@ -194,6 +201,7 @@
     [self dismissViewControllerAnimated:YES completion:^{
         if (self.isPageEdit) {
             [self.pdfView.document writeToURL:self.pdfView.document.documentURL];
+            [self.pdfView goToPageIndex:self.pageIndex animated:NO];
             if (self.pageEditDelegate && [self.pageEditDelegate respondsToSelector:@selector(pageEditViewControllerDone:)]) {
                 [self.pageEditDelegate pageEditViewControllerDone:self];
             }
@@ -419,6 +427,7 @@
         [self updateTitle];
         [cell setSelected:YES];
     } else {
+        [self.pdfView.document writeToURL:self.pdfView.document.documentURL];
         if([self.pageEditDelegate respondsToSelector:@selector(pageEditViewController:pageIndex:)]) {
             [self.pageEditDelegate pageEditViewController:self pageIndex:indexPath.item];
         }

+ 7 - 1
compdfkit-tools/compdfkit-tools/PageEdit/Views/CPDFPageEditViewCell.h

@@ -14,10 +14,16 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-@interface CPDFPageEditViewCell : CPDFThumbnailViewCell
+@interface CPDFPageEditViewCell : UICollectionViewCell
 
 - (void)setEdit:(BOOL)editing;
 
+@property (nonatomic, strong) UILabel *textLabel;
+@property (nonatomic, strong) UIImageView *imageView;
+@property (nonatomic, assign) CGSize imageSize;
+
+- (void)setPageRef:(CGPDFPageRef)pageRef;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 32 - 0
compdfkit-tools/compdfkit-tools/PageEdit/Views/CPDFPageEditViewCell.m

@@ -22,6 +22,18 @@
 
 - (instancetype)initWithFrame:(CGRect)frame {
     if (self = [super initWithFrame:frame]) {
+        _imageView = [[UIImageView alloc] init];
+        _imageView.layer.borderWidth = 1.0;
+        _imageView.layer.borderColor = [UIColor colorWithRed:221/255.0 green:233/255.0 blue:255/255.0 alpha:1.0].CGColor;
+        [self.contentView addSubview:_imageView];
+        
+        _textLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, frame.size.height - 12, frame.size.width, 12)];
+        _textLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
+        _textLabel.textAlignment = NSTextAlignmentCenter;
+        _textLabel.font = [UIFont systemFontOfSize:13];
+        _textLabel.textColor = [UIColor blackColor];
+        [self.contentView addSubview:_textLabel];
+        
         self.selectButton = [[UIButton alloc] initWithFrame:CGRectMake(5, 5, 20, 20)];
         self.selectButton.selected = self.selected;
         [_selectButton setImage:[UIImage imageNamed:@"CPageEditToolBarImageSelectOff" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
@@ -36,6 +48,12 @@
 
 - (void)layoutSubviews {
     [super layoutSubviews];
+    
+    _imageView.frame = CGRectMake((self.frame.size.width - self.imageSize.width)/2, (self.frame.size.height - 14 - self.imageSize.height) / 2, self.imageSize.width, self.imageSize.height);
+    
+    CGFloat startW = [self.textLabel.text sizeWithFont:[UIFont systemFontOfSize:10] constrainedToSize:CGSizeMake(MAXFLOAT, 12)].width;
+    //restSize
+    _textLabel.frame = CGRectMake(self.frame.size.width/2 - (startW + 20)/2, self.imageSize.height + (self.frame.size.height - 14 - self.imageSize.height) / 2, startW + 20, 12);
 }
 
 - (void)setEdit:(BOOL)editing {
@@ -47,6 +65,20 @@
     [self layoutSubviews];
 }
 
+- (void)setPageRef:(CGPDFPageRef)pageRef {
+    CGRect boxRect = CGRectZero;
+    if (pageRef) {
+        boxRect = CGPDFPageGetBoxRect(pageRef, kCGPDFCropBox);
+        CGRect displayBounds = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height - 12);
+        CGAffineTransform transform = CGPDFPageGetDrawingTransform(pageRef,
+                                                                   kCGPDFCropBox,
+                                                                   displayBounds,
+                                                                   0,
+                                                                   true);
+        boxRect = CGRectApplyAffineTransform(boxRect, transform);
+    }
+}
+
 - (void)setSelected:(BOOL)selected {
     [super setSelected:selected];
     if (selected) {