Sfoglia il codice sorgente

PDFTools(iOS)-修改图片编辑保存和增加第三方presentViewController的模态触碰事件

yangliuhua 1 anno fa
parent
commit
c296999755

+ 21 - 2
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFSignature/CPDFSignatureEditViewController.m

@@ -236,10 +236,25 @@
     [self updatePreferredContentSizeWithTraitCollection:newCollection];
 }
 
+
+
 #pragma mark - Private Methods
 
 - (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection {
-    self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 350 : 750);
+    CGFloat width = [UIScreen mainScreen].bounds.size.width;
+    CGFloat height = [UIScreen mainScreen].bounds.size.height;
+    
+    CGFloat mWidth = fmin(width, height);
+    CGFloat mHeight = fmax(width, height);
+    
+    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)createGestureRecognizer {
@@ -410,6 +425,10 @@
         imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
         imagePickerController.allowsEditing = YES;
         imagePickerController.modalPresentationStyle = UIModalPresentationPopover;
+        if (UIUserInterfaceIdiomPad == UI_USER_INTERFACE_IDIOM()) {
+            imagePickerController.popoverPresentationController.sourceView = self.segmentedControl;;
+            imagePickerController.popoverPresentationController.sourceRect = CGRectMake(CGRectGetMaxX(self.segmentedControl.bounds), CGRectGetMaxY(self.segmentedControl.bounds), 1, 1);
+        }
         [self presentViewController:imagePickerController animated:YES completion:nil];
     }];
     
@@ -437,7 +456,7 @@
 
 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
     [picker dismissViewControllerAnimated:YES completion:nil];
-    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
+    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
     
     UIImageOrientation imageOrientation = image.imageOrientation;
     if (imageOrientation!=UIImageOrientationUp) {

+ 5 - 2
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFStamp/CPDFStampViewController.m

@@ -297,6 +297,10 @@ PDFAnnotationStampKey const PDFAnnotationStampKeyShape = @"PDFAnnotationStampKey
         imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
         imagePickerController.allowsEditing = YES;
         imagePickerController.modalPresentationStyle = UIModalPresentationPopover;
+        if (UIUserInterfaceIdiomPad == UI_USER_INTERFACE_IDIOM()) {
+            imagePickerController.popoverPresentationController.sourceView = self.imageButton;
+            imagePickerController.popoverPresentationController.sourceRect = self.imageButton.bounds;
+        }
         [self presentViewController:imagePickerController animated:YES completion:nil];
     }];
     
@@ -339,7 +343,7 @@ PDFAnnotationStampKey const PDFAnnotationStampKeyShape = @"PDFAnnotationStampKey
 
 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
     [picker dismissViewControllerAnimated:YES completion:nil];
-    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
+    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
     
     UIImageOrientation imageOrientation = image.imageOrientation;
     if (imageOrientation!=UIImageOrientationUp) {
@@ -397,7 +401,6 @@ PDFAnnotationStampKey const PDFAnnotationStampKeyShape = @"PDFAnnotationStampKey
         // This is an iPhone or iPod touch
         self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? mWidth*0.9 : mHeight*0.9);
     }
-   
 }
 
 #pragma mark - Action

+ 13 - 0
compdfkit-tools/compdfkit-tools/Common/Utils/AAPLCustomPresentationController.h

@@ -12,5 +12,18 @@
 
 @import UIKit;
 
+@class AAPLCustomPresentationController;
+
+@protocol AAPLCustomPresentationControllerDelegate <NSObject>
+
+@optional
+
+- (void)AAPLCustomPresentationControllerTap:(AAPLCustomPresentationController *)AAPLCustomPresentationController;
+
+@end
+
 @interface AAPLCustomPresentationController : UIPresentationController <UIViewControllerTransitioningDelegate>
+
+@property (nonatomic, weak) id<AAPLCustomPresentationControllerDelegate> tapDelegate;
+
 @end

+ 3 - 0
compdfkit-tools/compdfkit-tools/Common/Utils/AAPLCustomPresentationController.m

@@ -231,6 +231,9 @@
 - (IBAction)dimmingViewTapped:(UITapGestureRecognizer*)sender
 {
     [self.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
+    if (self.tapDelegate && [self.tapDelegate respondsToSelector:@selector(AAPLCustomPresentationControllerTap:)]) {
+        [self.tapDelegate AAPLCustomPresentationControllerTap:self];
+    }
 }
 
 #pragma mark -

File diff suppressed because it is too large
+ 13 - 14
compdfkit-tools/compdfkit-tools/Common/Views/PDFAnnotationBar/CPDFAnnotationBar.m


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

@@ -195,8 +195,8 @@
     if ([self.activeAnnotation isKindOfClass:[CPDFSignatureAnnotation class]]) {
         [(CPDFSignatureAnnotation *)self.activeAnnotation signature];
         
-        [self updateActiveAnnotations:@[]];
         [self setNeedsDisplayForPage:self.activeAnnotation.page];
+        [self updateActiveAnnotations:@[]];
         [self updateScrollEnabled];
     }
 }