瀏覽代碼

PDFTools(iOS)-QA_bug 页面移动刷新和toolbar自适应问题

yangliuhua 1 年之前
父節點
當前提交
ef96b57e74

+ 1 - 1
ComPDFKit/ComPDFKit/CPDFViewController.m

@@ -523,7 +523,7 @@
     [self.annotationBar buttonItemClicked_open:self.titleButton];
 }
 
-- (void)PDFListViewCustomMenuClick:(CPDFListView *)pdfView identifier:(NSString *)menuIdentifier {
+- (void)PDFListViewCustomMenuClick:(CPDFListView *)pdfView identifier:(NSString *)menuIdentifier point:(CGPoint)point {
     if([menuIdentifier isEqualToString:@"PropertyItem"]){
         self.editMode = CPDFEditModeText;
         [self showMenuList];

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

@@ -23,6 +23,8 @@
 
 @property(nonatomic, strong) CPDFEditToolBar * toolBar;
 
+@property(nonatomic, assign) CGPoint menuPoint;
+
 @property (nonatomic, strong) CPDFSignatureWidgetAnnotation * signatureAnnotation;
 
 @end
@@ -175,8 +177,9 @@
 
 #pragma mark - CPDFViewDelegate
 
-- (void)PDFListViewCustomMenuClick:(CPDFListView *)pdfView identifier:(NSString *)menuIdentifier {
+- (void)PDFListViewCustomMenuClick:(CPDFListView *)pdfView identifier:(NSString *)menuIdentifier point:(CGPoint)point {
     if([menuIdentifier isEqualToString:@"PropertyItem"]) {
+        self.menuPoint = point;
         self.editMode = CPDFEditModeText;
         [self showMenuList];
         [self.toolBar updateButtonState];
@@ -291,6 +294,10 @@
         
         [self presentViewController:self.baseVC animated:YES completion:nil];
     }
+    
+    if (self.menuPoint.y < self.pdfListView.documentView.visibleSize.height/2) {
+        [self.pdfListView goToRect:CGRectMake(self.menuPoint.x, self.pdfListView.documentView.visibleSize.height/2-50, 1, 1) onPage:[self.pdfListView.document pageAtIndex:self.pdfListView.currentPageIndex] animated:YES];
+    }
 }
 
 #pragma mark - CPDFSignatureViewControllerDelegate

+ 2 - 3
compdfkit-tools/compdfkit-tools/Common/Views/PDFView/PDFListView/CPDFListView+Edit.m

@@ -15,7 +15,6 @@
 
 @implementation CPDFListView (Edit)
  
-
 - (NSArray<UIMenuItem *> *)menuItemsEditingAtPoint:(CGPoint)point forPage:(CPDFPage *)page{
     
     NSArray *menuItem = [super menuItemsEditingAtPoint:point forPage:page];
@@ -237,8 +236,8 @@
 
 - (void)propertyEditingItemAction:(UIMenuItem*)menuItem {
     
-    if(self.performDelegate && [self.performDelegate respondsToSelector:@selector(PDFListViewCustomMenuClick:identifier:)]){
-        [self.performDelegate PDFListViewCustomMenuClick:self identifier:@"PropertyItem"];
+    if(self.performDelegate && [self.performDelegate respondsToSelector:@selector(PDFListViewCustomMenuClick:identifier:point:)]){
+        [self.performDelegate PDFListViewCustomMenuClick:self identifier:@"PropertyItem" point:self.menuPoint];
     }
 }
 

+ 1 - 1
compdfkit-tools/compdfkit-tools/Common/Views/PDFView/PDFListView/CPDFListView.h

@@ -78,7 +78,7 @@ extern NSNotificationName const CPDFListViewAnnotationsOperationChangeNotificati
 
 - (void)PDFListViewPerformTouchEnded:(CPDFListView *)pdfListView;
 
-- (void)PDFListViewCustomMenuClick:(CPDFListView *)pdfListView identifier:(NSString *)menuIdentifier;
+- (void)PDFListViewCustomMenuClick:(CPDFListView *)pdfListView identifier:(NSString *)menuIdentifier point:(CGPoint)point;
 
 - (void)PDFListViewChangedToolMode:(CPDFListView *)pdfListView forToolMode:(CToolModel)toolMode;
 

+ 15 - 9
compdfkit-tools/compdfkit-tools/PageEdit/Control/CPDFPageEditViewController.m

@@ -98,7 +98,10 @@
 }
 
 - (void)viewWillLayoutSubviews {
-    
+    CGFloat height = 50.0;
+    if (@available(iOS 11.0, *))
+        height += self.view.safeAreaInsets.bottom;
+    self.pageEditToolBar.frame = CGRectMake(0, self.view.frame.size.height - height, self.view.frame.size.width, height);
     if (@available(iOS 11.0, *)) {
         self.headerView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.safeAreaInsets.top + 50);
         self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, self.view.safeAreaInsets.top, 120, 50);
@@ -125,11 +128,7 @@
     self.editBtn.hidden = YES;
     self.isSelecAll = NO;
     
-    CGFloat height = 50.0;
-    if (@available(iOS 11.0, *))
-        height += self.view.safeAreaInsets.bottom;
-    
-    self.pageEditToolBar = [[CPageEditToolBar alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - height, self.view.frame.size.width, height)];
+    self.pageEditToolBar = [[CPageEditToolBar alloc] init];
     self.pageEditToolBar.pdfView = self.pdfView;
     self.pageEditToolBar.currentPageIndex = -1;
     self.pageEditToolBar.delegate = self;
@@ -248,6 +247,15 @@
     }
 }
 
+- (void)refreshPageIndex {
+   NSInteger count = [self.collectionView numberOfItemsInSection:0];
+    for (NSInteger i = 0; i < count; i++) {
+        NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
+        CPDFPageEditViewCell *cell = (CPDFPageEditViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
+        cell.textLabel.text = [NSString stringWithFormat:@"%lu", i+1];
+    }
+}
+
 #pragma mark - GestureRecognized
 
 - (void)longPressGestureRecognized:(UILongPressGestureRecognizer *)gestureRecognizer {
@@ -272,7 +280,7 @@
         case UIGestureRecognizerStateEnded:
         {
             [self.collectionView endInteractiveMovement];
-            [self.collectionView reloadData];
+            [self refreshPageIndex];
         }
             break;
         default:
@@ -312,7 +320,6 @@
         [self.pdfView.document movePageAtIndex:sourceIndexPath.item withPageAtIndex:destinationIndexPath.item];
         self.isPageEdit = YES;
         [self updateTitle];
-        [self.collectionView reloadData];
     }
 }
 
@@ -431,7 +438,6 @@
         }
         [self.collectionView reloadItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
         [self.collectionView selectItemAtIndexPath:indexPath animated:NO scrollPosition:UICollectionViewScrollPositionNone];
-;
     }
     [self updateTitle];
     [self.pageEditToolBar reloadData];