2 Коміти 190725aefe ... ec6e406178

Автор SHA1 Опис Дата
  chenyu ec6e406178 Merge branch 'compdfkit_demo_ios' of git.kdan.cc:others/kmpdfkit_demo into compdfkit_demo_ios 1 рік тому
  chenyu c3252faf93 PDFTools(iOS)- 修复insert a blank page bug 1 рік тому

+ 82 - 18
compdfkit-tools/compdfkit-tools/PageEdit/Control/CPDFPageInsertViewController.m

@@ -172,6 +172,7 @@
     switch (indexPath.row) {
         case 0:
             [cell setCellStyle:CInsertBlankPageCellSize label:self.dataArray[indexPath.row]];
+            cell.buttonSelectedStatus = self.isSelect;
             break;
         case 1:
         {
@@ -214,6 +215,66 @@
         }
             break;
         case 4:
+        {
+            if(self.isSelect){
+                [cell setCellStyle:CInsertBlankPageCellDirection label:self.dataArray[indexPath.row]];
+                cell.verticalPageBtn.backgroundColor = [CPDFColorUtils CAnnotationBarSelectBackgroundColor];
+            }else{
+                [cell setCellStyle:CInsertBlankPageCellLocationSelect label:self.dataArray[indexPath.row]];
+                if (![self.pageLoactionBtns containsObject:cell.locationSelectBtn]) {
+                    [self.pageLoactionBtns addObject:cell.locationSelectBtn];
+                }
+                cell.separatorInset = UIEdgeInsetsMake(0, self.view.bounds.size.width, 0, 0);
+            }
+
+        }
+            break;
+        case 5:
+        {
+            if(self.isSelect) {
+                [cell setCellStyle:CInsertBlankPageCellLocation label:self.dataArray[indexPath.row]];
+            }else{
+                [cell setCellStyle:CInsertBlankPageCellLocationSelect label:self.dataArray[indexPath.row]];
+                if (![self.pageLoactionBtns containsObject:cell.locationSelectBtn]) {
+                    [self.pageLoactionBtns addObject:cell.locationSelectBtn];
+                }
+                if (self.currentPageIndex) {
+                    self.preCell = cell;
+                    cell.locationSelectBtn.selected = !cell.locationSelectBtn.selected;
+                    cell.locationSelectLabel.textColor = [CPDFColorUtils CPageEditToolbarFontColor];
+                }
+                cell.separatorInset = UIEdgeInsetsMake(0, self.view.bounds.size.width, 0, 0);
+            }
+
+        }
+            break;
+        case 6:
+        {
+            if(self.isSelect) {
+                [cell setCellStyle:CInsertBlankPageCellLocationSelect label:self.dataArray[indexPath.row]];
+                if (!self.currentPageIndex) {
+                    self.preCell = cell;
+                    cell.locationSelectBtn.selected = !cell.locationSelectBtn.selected;
+                    cell.locationSelectLabel.textColor = [CPDFColorUtils CPageEditToolbarFontColor];
+                }
+                
+                if (![self.pageLoactionBtns containsObject:cell.locationSelectBtn]) {
+                    [self.pageLoactionBtns addObject:cell.locationSelectBtn];
+                }
+                cell.separatorInset = UIEdgeInsetsMake(0, self.view.bounds.size.width, 0, 0);
+            }else{
+                [cell setCellStyle:CInsertBlankPageCellLocationTextFiled label:self.dataArray[indexPath.row]];
+                if (self.currentPageIndex) {
+                    cell.locationTextField.text = [NSString stringWithFormat:@"%lu", self.currentPageIndex];
+                    self.pageModel.pageIndex = self.currentPageIndex-1;
+                }
+                self.locationTextField = cell.locationTextField;
+                cell.separatorInset = UIEdgeInsetsMake(0, self.view.bounds.size.width, 0, 0);
+            }
+
+        }
+            break;
+        case 7:
         {
             [cell setCellStyle:CInsertBlankPageCellLocationSelect label:self.dataArray[indexPath.row]];
             if (![self.pageLoactionBtns containsObject:cell.locationSelectBtn]) {
@@ -222,7 +283,8 @@
             cell.separatorInset = UIEdgeInsetsMake(0, self.view.bounds.size.width, 0, 0);
         }
             break;
-        case 5:
+        
+        case 8:
         {
             [cell setCellStyle:CInsertBlankPageCellLocationSelect label:self.dataArray[indexPath.row]];
             if (![self.pageLoactionBtns containsObject:cell.locationSelectBtn]) {
@@ -236,7 +298,8 @@
             cell.separatorInset = UIEdgeInsetsMake(0, self.view.bounds.size.width, 0, 0);
         }
             break;
-        case 6:
+            
+        case 9:
         {
             [cell setCellStyle:CInsertBlankPageCellLocationTextFiled label:self.dataArray[indexPath.row]];
             if (self.currentPageIndex) {
@@ -247,7 +310,8 @@
             cell.separatorInset = UIEdgeInsetsMake(0, self.view.bounds.size.width, 0, 0);
         }
             break;
-        case 7:
+            
+        case 10:
         {
             [cell setCellStyle:CInsertBlankPageCellLocationSelect label:self.dataArray[indexPath.row]];
             if (![self.pageLoactionBtns containsObject:cell.locationSelectBtn]) {
@@ -311,37 +375,37 @@
     
     if (isSelect) {
         NSInteger t = indexPath.row;
+        NSLog(@"t is %zd",t);
         NSMutableArray *array = [NSMutableArray array];
         NSMutableArray *data = [NSMutableArray arrayWithArray:self.dataArray];
         for (NSString *str in szieArray) {
             t++;
-            NSIndexPath* path = [NSIndexPath indexPathForRow:t inSection:0];
-            [array addObject:path];
+            if([self.dataArray containsObject:str]){
+                
+            }else{
+                [data insertObject:str atIndex:t];
+            }
             
-            [data insertObject:str atIndex:t];
         }
         self.dataArray = (NSArray *)data;
-        [self.tableView insertRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationFade];
-//        [self.tableView reloadData];
-//        NSIndexPath* path = [NSIndexPath indexPathForRow:0 inSection:0];
-//        CInsertBlankPageCell *cell = [self.tableView cellForRowAtIndexPath:path];
-//
-//        NSInteger sizeIndex = [szieArray indexOfObject:cell.sizeLabel.text];
-//        NSIndexPath *index = [NSIndexPath indexPathForItem:sizeIndex+1 inSection:0];
-//        [self.tableView selectRowAtIndexPath:index animated:NO scrollPosition:UITableViewScrollPositionMiddle];
+        
     } else {
         NSInteger t = indexPath.row;
         NSMutableArray *array = [NSMutableArray array];
         NSMutableArray *data = [NSMutableArray arrayWithArray:self.dataArray];
         for (int i = 0; i < szieArray.count; i++) {
             t++;
-            NSIndexPath* path = [NSIndexPath indexPathForRow:t inSection:0];
-            [array addObject:path];
-            [data removeObjectAtIndex:t];
+            NSString * str = szieArray[i];
+            if([data containsObject:str]) {
+                [data removeObject:str];
+            }
         }
         self.dataArray = (NSArray *)data;
-        [self.tableView deleteRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationFade];
     }
+    
+    NSLog(@"dataArray %@",self.dataArray);
+    
+    [self.tableView reloadData];
 }
 
 - (void)insertBlankPageCellLocation:(CInsertBlankPageCell *)insertBlankPageCell button:(nonnull UIButton *)buttom {

+ 4 - 0
compdfkit-tools/compdfkit-tools/PageEdit/Views/CInsertBlankPageCell.h

@@ -75,8 +75,12 @@ typedef NS_ENUM(NSInteger, CInsertBlankPageCellType) {
 
 @property (nullable, nonatomic, strong) UITextField *rangeTextField;
 
+@property (nonatomic, assign) BOOL  buttonSelectedStatus;
+
+
 - (void)setCellStyle:(CInsertBlankPageCellType)cellType label:(NSString *)label;
 
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 12 - 3
compdfkit-tools/compdfkit-tools/PageEdit/Views/CInsertBlankPageCell.m

@@ -269,13 +269,22 @@
     return  res;
 }
 
+- (void)setButtonSelectedStatus:(BOOL)buttonSelectedStatus {
+    _buttonSelectedStatus = buttonSelectedStatus;
+    
+    if(buttonSelectedStatus == YES) {
+        [self.sizeSelectBtn setSelected:YES];
+    }else{
+        [self.sizeSelectBtn setSelected:NO];
+    }
+}
 #pragma mark - Action
 
 - (void)buttonItemClicked_size:(UIButton *)button {
-    
+    button.selected = !button.selected;
+
     if (self.delegate && [self.delegate respondsToSelector:@selector(insertBlankPageCell:isSelect:)]) {
-        self.sizeSelectBtn.selected = !self.sizeSelectBtn.selected;
-        [self.delegate insertBlankPageCell:self isSelect:self.sizeSelectBtn.selected];
+        [self.delegate insertBlankPageCell:self isSelect:button.selected];
     }
 }