ソースを参照

PDFPageEdit(iOS)-页面跳转小概率会挂问题

yangliuhua 1 年間 前
コミット
c1f81ce7f6

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

@@ -78,16 +78,17 @@
     [weakSelf.pdfListView reloadInputViews];
 }
 
-- (void)pageEditViewController:(CPDFPageEditViewController *)pageEditViewController pageIndex:(NSInteger)pageIndex {
-    __weak typeof(self) weakSelf = self;
-    [weakSelf reloadDocumentWithFilePath:self.filePath password:nil completion:^(BOOL result) {
+- (void)pageEditViewController:(CPDFPageEditViewController *)pageEditViewController pageIndex:(NSInteger)pageIndex isPageEdit:(BOOL)isPageEdit {
+    if (isPageEdit) {
+        __weak typeof(self) weakSelf = self;
+        [weakSelf reloadDocumentWithFilePath:self.filePath password:nil completion:^(BOOL result) {
+            [weakSelf.pdfListView reloadInputViews];
+        }];
+        
         [weakSelf.pdfListView reloadInputViews];
-    }];
-    
-    [weakSelf.pdfListView reloadInputViews];
+    }
     
     [self.pdfListView goToPageIndex:pageIndex animated:NO];
-    [self.navigationController popViewControllerAnimated:YES];
 }
 
 #pragma mark - CPDFListViewDelegate

+ 6 - 1
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFSignature/CPDFSignatureEditViewController.m

@@ -540,7 +540,12 @@
 
 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
     [picker dismissViewControllerAnimated:YES completion:nil];
-    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
+    UIImage *image;
+    if ([info objectForKey:UIImagePickerControllerEditedImage]) {
+        image = [info objectForKey:UIImagePickerControllerEditedImage];
+    } else if ([info objectForKey:UIImagePickerControllerOriginalImage]) {
+        image = [info objectForKey:UIImagePickerControllerOriginalImage];
+    }
     
     if (image) {
         self.isImageSignature = YES;

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

@@ -346,7 +346,12 @@ PDFAnnotationStampKey const PDFAnnotationStampKeyShape = @"PDFAnnotationStampKey
 
 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
     [picker dismissViewControllerAnimated:YES completion:nil];
-    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
+    UIImage *image;
+    if ([info objectForKey:UIImagePickerControllerEditedImage]) {
+        image = [info objectForKey:UIImagePickerControllerEditedImage];
+    } else if ([info objectForKey:UIImagePickerControllerOriginalImage]) {
+        image = [info objectForKey:UIImagePickerControllerOriginalImage];
+    }
     
     UIImageOrientation imageOrientation = image.imageOrientation;
     if (imageOrientation!=UIImageOrientationUp) {

+ 8 - 2
compdfkit-tools/compdfkit-tools/Common/Views/PDFAnnotationBar/CPDFAnnotationBar.m

@@ -157,7 +157,8 @@
     self.menuPoint = point;
     AAPLCustomPresentationController *presentationController NS_VALID_UNTIL_END_OF_SCOPE;
     CPDFStampViewController *stampVC = [[CPDFStampViewController alloc] init];
-    presentationController = [[AAPLCustomPresentationController alloc] initWithPresentedViewController:self.signatureVC presentingViewController:self.parentVC];
+    presentationController = [[AAPLCustomPresentationController alloc] initWithPresentedViewController:stampVC presentingViewController:self.parentVC];
+    presentationController.tapDelegate = self;
     stampVC.delegate = self;
     stampVC.transitioningDelegate = presentationController;
     [self.parentVC presentViewController:stampVC animated:YES completion:nil];
@@ -628,7 +629,12 @@
 
 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
     [picker dismissViewControllerAnimated:YES completion:nil];
-    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
+    UIImage *image;
+    if ([info objectForKey:UIImagePickerControllerEditedImage]) {
+        image = [info objectForKey:UIImagePickerControllerEditedImage];
+    } else if ([info objectForKey:UIImagePickerControllerOriginalImage]) {
+        image = [info objectForKey:UIImagePickerControllerOriginalImage];
+    }
     
     UIImageOrientation imageOrientation = image.imageOrientation;
     if (imageOrientation!=UIImageOrientationUp) {

+ 1 - 1
compdfkit-tools/compdfkit-tools/PageEdit/Control/CPDFPageEditViewController.h

@@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 - (void)pageEditViewControllerDone:(CPDFPageEditViewController *)pageEditViewController;
 
-- (void)pageEditViewController:(CPDFPageEditViewController *)pageEditViewController pageIndex:(NSInteger)pageIndex;
+- (void)pageEditViewController:(CPDFPageEditViewController *)pageEditViewController pageIndex:(NSInteger)pageIndex isPageEdit:(BOOL)isPageEdit;
 
 @end
 

+ 7 - 7
compdfkit-tools/compdfkit-tools/PageEdit/Control/CPDFPageEditViewController.m

@@ -185,7 +185,7 @@
     self.selectAllBtn.hidden = YES;
     
     [self.collectionView reloadData];
-    
+
     self.pageIndex = [self.pdfView.document indexForPage:self.currentPage];
     NSIndexPath *indexPath = [NSIndexPath indexPathForItem:self.pageIndex inSection:0];
 
@@ -427,14 +427,14 @@
         [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];
+        if (self.isPageEdit) {
+            [self.pdfView.document writeToURL:self.pdfView.document.documentURL];
+        }
+        if([self.pageEditDelegate respondsToSelector:@selector(pageEditViewController:pageIndex:isPageEdit:)]) {
+            [self.pageEditDelegate pageEditViewController:self pageIndex:indexPath.item isPageEdit:self.isPageEdit];
         }
         
-        [self dismissViewControllerAnimated:YES completion:^{
-                
-        }];
+        [self dismissViewControllerAnimated:YES completion:nil];
     }
 }
 

+ 1 - 1
compdfkit-tools/compdfkit-tools/PageEdit/Views/CPDFPageEditViewCell.m

@@ -94,7 +94,7 @@
         self.imageView.layer.borderColor = [UIColor colorWithRed:242/255. green:242/255. blue:242/255. alpha:1.].CGColor;
         self.imageView.layer.borderWidth = 1;
     }
-    
+
     self.selectButton.selected = selected;
 }