Browse Source

PDFTools(iOS) - pdfbookmark的交互优化

yangliuhua 1 year ago
parent
commit
739b099990

+ 1 - 1
compdfkit-tools/compdfkit-tools/Common/Controls/BOTA/CPDFBOTAViewController.m

@@ -69,7 +69,7 @@
     [self addChildViewController:_bookmarkViewController];
     
     
-    NSArray *segmmentArray = [NSArray arrayWithObjects:NSLocalizedString(@"Thumbnail", nil), NSLocalizedString(@"Book mark", nil), nil];
+    NSArray *segmmentArray = [NSArray arrayWithObjects:NSLocalizedString(@"Outline", nil), NSLocalizedString(@"Bookmark", nil), nil];
     _segmentedControl = [[UISegmentedControl alloc] initWithItems:segmmentArray];
     _segmentedControl.selectedSegmentIndex = 0;
     _segmentedControl.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

+ 1 - 1
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/CPDFBookmarkViewCell.m

@@ -51,7 +51,7 @@
         if (tableView) {
             NSIndexPath *indexPath = [tableView indexPathForCell:self];
             [tableView setEditing:YES animated:YES];
-            [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
+            [tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionMiddle];
         }
 }
 

+ 9 - 9
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/CPDFBookmarkViewController.m

@@ -49,7 +49,6 @@
     _tableView.rowHeight = UITableViewAutomaticDimension;
     _tableView.estimatedRowHeight = 60;
     _tableView.tableFooterView = [[UIView alloc] init];
-//    [_tableView setEditing:YES animated:YES];
     [self.view addSubview:self.tableView];
     
     _noDataLabel = [[UILabel alloc] init];
@@ -60,8 +59,8 @@
     _noDataLabel.autoresizingMask = UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
     [self.view addSubview:self.noDataLabel];
     
-    _addBookmarkBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width - self.view.safeAreaInsets.right - 60, self.view.frame.size.height - self.view.safeAreaInsets.bottom - 60, 60, 60)];
-    _addBookmarkBtn.layer.cornerRadius = 30;
+    _addBookmarkBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width - self.view.safeAreaInsets.right - 50, self.view.frame.size.height - self.view.safeAreaInsets.bottom - 50, 50, 50)];
+    _addBookmarkBtn.layer.cornerRadius = 25;
     _addBookmarkBtn.layer.masksToBounds = YES;
     _addBookmarkBtn.layer.borderWidth = 1.0;
     _addBookmarkBtn.layer.borderColor = [UIColor blueColor].CGColor;
@@ -101,15 +100,15 @@
 }
 
 - (void)panaddBookmarkBtn:(UIPanGestureRecognizer *)recognizer {
-    CGPoint point = [recognizer translationInView:_tableView];
-    CGRect documentFrame = _tableView.frame;
-    documentFrame.origin.x -= _tableView.frame.origin.x;
-    documentFrame.origin.y -= _tableView.frame.origin.y;
+    CGPoint point = [recognizer translationInView:self.view];
+    CGRect documentFrame = self.view.frame;
+    documentFrame.origin.x -= self.view.frame.origin.x;
+    documentFrame.origin.y -= self.view.frame.origin.y;
     
-    [_addBookmarkBtn setCenter:CGPointMake(_addBookmarkBtn.center.x + point.x, _addBookmarkBtn.center.y + point.y)];
+    [_addBookmarkBtn setCenter:CGPointMake(_addBookmarkBtn.center.x + point.x / 15, _addBookmarkBtn.center.y + point.y / 15)];
     
     if (!CGRectContainsRect(documentFrame,_addBookmarkBtn.frame)) {
-        [_addBookmarkBtn setCenter:CGPointMake(_addBookmarkBtn.center.x - point.x, _addBookmarkBtn.center.y - point.y)];
+        [_addBookmarkBtn setCenter:CGPointMake(_addBookmarkBtn.center.x - point.x / 15, _addBookmarkBtn.center.y - point.y / 15)];
     }
 }
 
@@ -179,6 +178,7 @@
         UIAlertAction *addAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Add", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
             CPDFBookmarkViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
             cell.titleLabel.text = alert.textFields.firstObject.text;
+            self.pdfView.document.bookmarks[indexPath.row].label = alert.textFields.firstObject.text;
         }];
         
         [alert addAction:cancelAction];