Преглед на файлове

Merge branch 'compdfkit_demo_ios' of git.kdan.cc:others/kmpdfkit_demo into compdfkit_demo_ios

chenyu преди 1 година
родител
ревизия
4aa829ee4d

+ 78 - 0
Annotation-Ctrl-Demo/Annotation-Ctrl-Demo.xcodeproj/xcshareddata/xcschemes/Annotation-Ctrl-Demo.xcscheme

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+   LastUpgradeVersion = "1420"
+   version = "1.3">
+   <BuildAction
+      parallelizeBuildables = "YES"
+      buildImplicitDependencies = "YES">
+      <BuildActionEntries>
+         <BuildActionEntry
+            buildForTesting = "YES"
+            buildForRunning = "YES"
+            buildForProfiling = "YES"
+            buildForArchiving = "YES"
+            buildForAnalyzing = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C9AF184B29F267DD00EC4979"
+               BuildableName = "Annotation-Ctrl-Demo.app"
+               BlueprintName = "Annotation-Ctrl-Demo"
+               ReferencedContainer = "container:Annotation-Ctrl-Demo.xcodeproj">
+            </BuildableReference>
+         </BuildActionEntry>
+      </BuildActionEntries>
+   </BuildAction>
+   <TestAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      shouldUseLaunchSchemeArgsEnv = "YES">
+      <Testables>
+      </Testables>
+   </TestAction>
+   <LaunchAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      launchStyle = "0"
+      useCustomWorkingDirectory = "NO"
+      ignoresPersistentStateOnLaunch = "NO"
+      debugDocumentVersioning = "YES"
+      debugServiceExtension = "internal"
+      allowLocationSimulation = "YES">
+      <BuildableProductRunnable
+         runnableDebuggingMode = "0">
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "C9AF184B29F267DD00EC4979"
+            BuildableName = "Annotation-Ctrl-Demo.app"
+            BlueprintName = "Annotation-Ctrl-Demo"
+            ReferencedContainer = "container:Annotation-Ctrl-Demo.xcodeproj">
+         </BuildableReference>
+      </BuildableProductRunnable>
+   </LaunchAction>
+   <ProfileAction
+      buildConfiguration = "Release"
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      savedToolIdentifier = ""
+      useCustomWorkingDirectory = "NO"
+      debugDocumentVersioning = "YES">
+      <BuildableProductRunnable
+         runnableDebuggingMode = "0">
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "C9AF184B29F267DD00EC4979"
+            BuildableName = "Annotation-Ctrl-Demo.app"
+            BlueprintName = "Annotation-Ctrl-Demo"
+            ReferencedContainer = "container:Annotation-Ctrl-Demo.xcodeproj">
+         </BuildableReference>
+      </BuildableProductRunnable>
+   </ProfileAction>
+   <AnalyzeAction
+      buildConfiguration = "Debug">
+   </AnalyzeAction>
+   <ArchiveAction
+      buildConfiguration = "Release"
+      revealArchiveInOrganizer = "YES">
+   </ArchiveAction>
+</Scheme>

+ 2 - 0
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFLink/CPDFLinkViewController.h

@@ -39,6 +39,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property (nonatomic, assign) NSInteger pageCount;
 
+@property (nonatomic, assign) BOOL isLink;
+
 - (instancetype)initWithStyle:(CAnnotStyle *)annotStyle;
 
 @property (nonatomic, weak) id<CPDFLinkViewControllerDelegate> delegate;

+ 29 - 2
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFLink/CPDFLinkViewController.m

@@ -119,6 +119,33 @@
     [currentTextField becomeFirstResponder];
 }
 
+- (void)viewWillDisappear:(BOOL)animated {
+    
+}
+
+- (BOOL)isLink {
+    NSString *currentTextField = nil;
+
+    switch (self.segmentedControl.selectedSegmentIndex) {
+        case 0:
+            currentTextField = self.urlTextField.text;
+            break;
+        case 1:
+            currentTextField = self.pageTextField.text;
+            break;
+        default:
+        case 2:
+            currentTextField = self.emailTextField.text;
+            break;
+    }
+    
+    if (!([currentTextField isEqual:@""])) {
+        return YES;
+    } else {
+        return NO;
+    }
+}
+
 - (void)setLinkType:(CPDFLinkType)linkType {
     _linkType = linkType;
     
@@ -158,7 +185,7 @@
 
 - (void)viewWillLayoutSubviews {
     [super viewWillLayoutSubviews];
-    self.titleLabel.frame = CGRectMake(0, 17.5, self.view.frame.size.width, 25.0);
+    self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 5, 120, 50);
     self.headerView.frame = CGRectMake(0, 0, self.view.frame.size.width, 50);
     
     if (@available(iOS 11.0, *)) {
@@ -195,7 +222,7 @@
 
 - (void)initWithView {
     _titleLabel = [[UILabel alloc] init];
-    _titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
+    _titleLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
     _titleLabel.text = NSLocalizedString(@"Link to", nil);
     _titleLabel.textAlignment = NSTextAlignmentCenter;
     _titleLabel.font = [UIFont systemFontOfSize:20];

+ 13 - 7
compdfkit-tools/compdfkit-tools/Common/Views/PDFAnnotationBar/CPDFAnnotationBar.m

@@ -66,6 +66,8 @@
 
 @property (nonatomic, strong) CPDFSignatureWidgetAnnotation * signatureAnnotation;
 
+@property (nonatomic, strong) CPDFLinkViewController *linkVC;
+
 @end
 
 @implementation CPDFAnnotationBar
@@ -475,13 +477,13 @@
             break;
         case CPDFToolbarLink:
         {
-            CPDFLinkViewController *linkVC = [[CPDFLinkViewController alloc] initWithStyle:annotStytle];
-            linkVC.pageCount = self.annotManage.pdfListView.document.pageCount;
-            linkVC.delegate = self;
-            presentationController = [[AAPLCustomPresentationController alloc] initWithPresentedViewController:linkVC presentingViewController:self.parentVC];
+            self.linkVC = [[CPDFLinkViewController alloc] initWithStyle:annotStytle];
+            self.linkVC.pageCount = self.annotManage.pdfListView.document.pageCount;
+            self.linkVC.delegate = self;
+            presentationController = [[AAPLCustomPresentationController alloc] initWithPresentedViewController:self.linkVC presentingViewController:self.parentVC];
             presentationController.tapDelegate = self;
-            linkVC.transitioningDelegate = presentationController;
-            [self.parentVC presentViewController:linkVC animated:YES completion:nil];
+            self.linkVC.transitioningDelegate = presentationController;
+            [self.parentVC presentViewController:self.linkVC animated:YES completion:nil];
         }
             break;
         default:
@@ -611,7 +613,11 @@
 - (void)AAPLCustomPresentationControllerTap:(AAPLCustomPresentationController *)AAPLCustomPresentationController {
     CPDFAnnotation *annotation = self.annotManage.pdfListView.activeAnnotations.firstObject;
     if([annotation isKindOfClass:[CPDFLinkAnnotation class]]) {
-        
+        if (!self.linkVC.isLink) {
+            [((CPDFAnnotation *)self.pdfListView.activeAnnotations.firstObject).page removeAnnotation:self.pdfListView.activeAnnotations.firstObject];
+            [self.annotManage.pdfListView setNeedsDisplayForPage:self.annotManage.pdfListView.activeAnnotation.page];
+            [self.annotManage.pdfListView updateActiveAnnotations:@[]];
+        }
     } else if (CPDFViewAnnotationModeSignature == self.selectedIndex || CPDFViewAnnotationModeStamp == self.selectedIndex) {
         self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
     }

+ 9 - 7
compdfkit-tools/compdfkit-tools/Common/Views/PDFProperties/CPDFAnnotationSampleView.m

@@ -244,15 +244,17 @@
             } else {
                 CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
             }
+            CGContextSetLineWidth(context, self.thickness);
             CGFloat dashLengths[2] = {6, self.dotted};
             CGContextSetLineDash(context, 0, dashLengths, 2);
-            CGRect insetRect = CGRectInset(self.centerRect, -self.thickness / 5.0, -self.thickness / 5.0);
-            UIBezierPath *path = [UIBezierPath bezierPathWithRect:insetRect];
-
-            CGContextSetLineWidth(context, self.thickness/2.0);
-            CGContextStrokeRect(context, insetRect);
-            [path setLineWidth:self.thickness/2.0];
-            [path stroke];
+            CGContextMoveToPoint(context, CGRectGetMinX(self.centerRect), CGRectGetMinY(self.centerRect));
+            CGContextAddLineToPoint(context, CGRectGetMaxX(self.centerRect), CGRectGetMinY(self.centerRect));
+            CGContextAddLineToPoint(context, CGRectGetMaxX(self.centerRect), CGRectGetMaxY(self.centerRect));
+            CGContextAddLineToPoint(context, CGRectGetMinX(self.centerRect), CGRectGetMaxY(self.centerRect));
+            CGContextAddLineToPoint(context, CGRectGetMinX(self.centerRect), CGRectGetMinY(self.centerRect));
+            CGContextAddLineToPoint(context, CGRectGetMinX(self.centerRect)+1, CGRectGetMinY(self.centerRect));
+            CGContextStrokePath(context);
+            
             CGContextFillRect(context, rect);
         }
             break;

+ 5 - 2
compdfkit-tools/compdfkit-tools/Viewer/PDFAnnotation/CPDFAnnotationViewController.m

@@ -94,11 +94,12 @@
         }
         _emptyLabel.font = [UIFont boldSystemFontOfSize:16.0];
         _emptyLabel.text = NSLocalizedString(@"No annotations", nil);
+        _emptyLabel.textColor = [UIColor grayColor];
         [_emptyLabel sizeToFit];
         [self.view addSubview:_emptyLabel];
         [self.view bringSubviewToFront:_emptyLabel];
-        _emptyLabel.frame = CGRectMake((self.view.frame.size.width - _emptyLabel.frame.size.width)/2, (self.view.frame.size.height - _emptyLabel.frame.size.height)/2, _emptyLabel.frame.size.width, _emptyLabel.frame.size.height);
-        _emptyLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
+        _emptyLabel.center = CGPointMake(self.view.bounds.size.width/2.0, self.view.bounds.size.height/2.0);
+        _emptyLabel.autoresizingMask = UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
     }
     return _emptyLabel;
 }
@@ -193,8 +194,10 @@ static NSInteger sortByDate(CPDFAnnotation *annot1, CPDFAnnotation *annot2, void
     NSInteger count = [self.sequenceList count];
     if (count < 1) {
         self.emptyLabel.hidden = NO;
+        self.tableView.hidden = YES;
     } else {
         self.emptyLabel.hidden = YES;
+        self.tableView.hidden = NO;
     }
 
     return count;