Prechádzať zdrojové kódy

PDFTool(iOS)-自测修改

dinglingui 1 rok pred
rodič
commit
6427084ddf

+ 10 - 1
Annotation-Ctrl-Demo/Annotation-Ctrl-Demo/CPDFViewController.m

@@ -359,6 +359,7 @@
         [_soundPlayBar showInView:self.pdfListView soundState:CPDFSoundStatePlay];
         [_soundPlayBar setURL:URL];
         [_soundPlayBar startAudioPlay];
+        [CPDFMediaManager shareManager].mediaState = CPDFMediaStateVedioPlaying;
     }
 }
 
@@ -539,12 +540,20 @@
 }
 
 - (void)soundPlayBarRecordCancel:(CPDFSoundPlayBar *)soundPlayBar {
+    if(CPDFSoundStateRecord == self.soundPlayBar.soundState) {
+        [self.pdfListView stopRecord];
+    }
+    [CPDFMediaManager shareManager].mediaState = CPDFMediaStateStop;
     self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
 }
 
+- (void)soundPlayBarPlayClose:(CPDFSoundPlayBar *)soundPlayBar {
+    [CPDFMediaManager shareManager].mediaState = CPDFMediaStateStop;
+}
+
 #pragma mark - CPDFPopMenuDelegate
 
-- (void)MenuDidClosedIn:(CPDFPopMenu *)menu isClosed:(BOOL)isClosed {
+- (void)menuDidClosedIn:(CPDFPopMenu *)menu isClosed:(BOOL)isClosed {
     self.popMenuClosed = isClosed;
 }
 

+ 8 - 8
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFShape/CPDFShapeCircleViewController.m

@@ -87,13 +87,6 @@
 #pragma mark - Protect Mehthods
 
 - (void)commomInitFromAnnotStyle {
-    self.sampleView.fillColor = self.annotStyle.color;
-    self.sampleView.opcity = self.annotStyle.opacity;
-    self.sampleView.thickness = self.annotStyle.lineWidth;
-    self.sampleView.dotted = self.dottedView.thicknessSlider.value;
-    self.sampleView.fillShapeColor = self.annotStyle.interiorColor;
-    [self.sampleView setNeedsDisplay];
-
     self.opacitySliderView.opacitySlider.value = self.annotStyle.opacity;
     self.opacitySliderView.startLabel.text = [NSString stringWithFormat:@"%d%%", (int)((self.opacitySliderView.opacitySlider.value/1)*100)];
     self.thicknessView.thicknessSlider.value = self.annotStyle.lineWidth;
@@ -101,6 +94,13 @@
     self.dashPattern = (NSMutableArray *)self.annotStyle.dashPattern;
     self.dottedView.thicknessSlider.value = [self.dashPattern.firstObject floatValue];
     self.dottedView.startLabel.text = [NSString stringWithFormat:@"%.1fpt", self.dottedView.thicknessSlider.value];
+    
+    self.sampleView.fillColor = self.annotStyle.color;
+    self.sampleView.opcity = self.annotStyle.opacity;
+    self.sampleView.thickness = self.annotStyle.lineWidth;
+    self.sampleView.dotted = self.dottedView.thicknessSlider.value;
+    self.sampleView.fillShapeColor = self.annotStyle.interiorColor;
+    [self.sampleView setNeedsDisplay];
 }
 
 - (void)commomInitTitle {
@@ -168,7 +168,7 @@
     } else if (thicknessSliderView == self.dottedView) {
         self.sampleView.dotted = thickness;
         self.annotStyle.style = CPDFBorderStyleDashed;
-        self.annotStyle.dashPattern = @[@10, [NSNumber numberWithFloat:(float)thickness]];
+        self.annotStyle.dashPattern = @[[NSNumber numberWithFloat:(float)thickness]];
         if (self.delegate && [self.delegate respondsToSelector:@selector(circleViewController:annotStyle:)]) {
             [self.delegate circleViewController:self annotStyle:self.annotStyle];
         }

+ 3 - 0
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFSound/CPDFSoundPlayBar.m

@@ -323,10 +323,13 @@ typedef NS_ENUM(NSInteger, CPDFAudioState) {
 - (IBAction)buttonItemClicked_Close:(id)sender {
     [self removeFromSuperview];
     if (self.soundState == CPDFSoundStateRecord) {
+        [_avAudioRecorder stop];
         if ([self.delegate respondsToSelector:@selector(soundPlayBarRecordCancel:)]) {
             [self.delegate soundPlayBarRecordCancel:self];
         }
     } else if(self.soundState == CPDFSoundStatePlay) {
+        [self stopAudioPlay];
+
         if ([self.delegate respondsToSelector:@selector(soundPlayBarPlayClose:)]) {
             [self.delegate soundPlayBarPlayClose:self];
         }

+ 8 - 1
compdfkit-tools/compdfkit-tools/Common/Model/CAnnotStyle.m

@@ -485,7 +485,11 @@
 
 - (NSArray *)dashPattern {
     if (self.isSelectAnnot) {
-        return self.annotation.dashPattern;
+        if(CPDFBorderStyleDashed == self.annotation.border.style) {
+            return self.annotation.dashPattern;
+        } else {
+            return 0;
+        }
     } else {
         NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
         NSInteger dashPattern = 0;
@@ -511,6 +515,9 @@
             default:
                 break;
         }
+        if(CPDFBorderStyleDashed != self.style) {
+            dashPattern=  0;
+        }
         return @[@(dashPattern)];
     }
 }

+ 43 - 35
compdfkit-tools/compdfkit-tools/Common/Views/PDFAnnotationBar/CPDFAnnotationBar.m

@@ -135,42 +135,48 @@
     CGFloat buttonOffset = 15;
     CGFloat buttonSize = 44;
     CGFloat topOffset = (46 - buttonSize)/2;
-
-    NSArray *images = @[@"CPDFAnnotationBarImageNote",
-                        @"CPDFAnnotationBarImageHighLight",
-                        @"CPDFAnnotationBarImageUnderline",
-                        @"CPDFAnnotationBarImageStrikeout",
-                        @"CPDFAnnotationBarImageSquiggly",
-                        @"CPDFAnnotationBarImageFreehand",
-                        @"CPDFAnnotationBarImagePencilDraw",
-                        @"CPDFAnnotationBarImageShapeCircle",
-                        @"CPDFAnnotationBarImageShapeRectangle",
-                        @"CPDFAnnotationBarImageShapeArrow",
-                        @"CPDFAnnotationBarImageShapeLine",
-                        @"CPDFAnnotationBarImageFreeText",
-                        @"CPDFAnnotationBarImageSignature",
-                        @"CPDFAnnotationBarImageStamp",
-                        @"CPDFAnnotationBarImageImage",
-                        @"CPDFAnnotationBarImageLink",
-                        @"CPDFAnnotationBarImageSound"];
     
-    NSArray *types = @[@(CPDFViewAnnotationModeNote),
-                       @(CPDFViewAnnotationModeHighlight),
-                       @(CPDFViewAnnotationModeUnderline),
-                       @(CPDFViewAnnotationModeStrikeout),
-                       @(CPDFViewAnnotationModeSquiggly),
-                       @(CPDFViewAnnotationModeInk),
-                       @(CPDFViewAnnotationModePencilDrawing),
-                       @(CPDFViewAnnotationModeCircle),
-                       @(CPDFViewAnnotationModeSquare),
-                       @(CPDFViewAnnotationModeArrow),
-                       @(CPDFViewAnnotationModeLine),
-                       @(CPDFViewAnnotationModeFreeText),
-                       @(CPDFViewAnnotationModeSignature),
-                       @(CPDFViewAnnotationModeStamp),
-                       @(CPDFViewAnnotationModeImage),
-                       @(CPDFViewAnnotationModeLink),
-                       @(CPDFViewAnnotationModeSound)];
+    NSMutableArray *images = [NSMutableArray arrayWithArray:@[@"CPDFAnnotationBarImageNote",
+                                                              @"CPDFAnnotationBarImageHighLight",
+                                                              @"CPDFAnnotationBarImageUnderline",
+                                                              @"CPDFAnnotationBarImageStrikeout",
+                                                              @"CPDFAnnotationBarImageSquiggly",
+                                                              @"CPDFAnnotationBarImageFreehand",
+                                                              @"CPDFAnnotationBarImagePencilDraw",
+                                                              @"CPDFAnnotationBarImageShapeCircle",
+                                                              @"CPDFAnnotationBarImageShapeRectangle",
+                                                              @"CPDFAnnotationBarImageShapeArrow",
+                                                              @"CPDFAnnotationBarImageShapeLine",
+                                                              @"CPDFAnnotationBarImageFreeText",
+                                                              @"CPDFAnnotationBarImageSignature",
+                                                              @"CPDFAnnotationBarImageStamp",
+                                                              @"CPDFAnnotationBarImageImage",
+                                                              @"CPDFAnnotationBarImageLink",
+                                                              @"CPDFAnnotationBarImageSound"]];
+    
+    NSMutableArray *types = [NSMutableArray arrayWithArray:@[@(CPDFViewAnnotationModeNote),
+                                                             @(CPDFViewAnnotationModeHighlight),
+                                                             @(CPDFViewAnnotationModeUnderline),
+                                                             @(CPDFViewAnnotationModeStrikeout),
+                                                             @(CPDFViewAnnotationModeSquiggly),
+                                                             @(CPDFViewAnnotationModeInk),
+                                                             @(CPDFViewAnnotationModePencilDrawing),
+                                                             @(CPDFViewAnnotationModeCircle),
+                                                             @(CPDFViewAnnotationModeSquare),
+                                                             @(CPDFViewAnnotationModeArrow),
+                                                             @(CPDFViewAnnotationModeLine),
+                                                             @(CPDFViewAnnotationModeFreeText),
+                                                             @(CPDFViewAnnotationModeSignature),
+                                                             @(CPDFViewAnnotationModeStamp),
+                                                             @(CPDFViewAnnotationModeImage),
+                                                             @(CPDFViewAnnotationModeLink),
+                                                             @(CPDFViewAnnotationModeSound)]];
+
+    if (@available(iOS 13.0, *)) {
+    } else {
+        [images removeObject:@"CPDFAnnotationBarImagePencilDraw"];
+        [types removeObject:@(CPDFViewAnnotationModePencilDrawing)];
+    }
     
     NSMutableArray *annotationBtns = [NSMutableArray array];
     for (int i = 0; i < types.count; i++) {
@@ -239,6 +245,8 @@
     [_redoBtn setImage:[UIImage imageNamed:@"CPDFAnnotationBarImageRedo" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
     [_redoBtn addTarget:self action:@selector(buttonItemClicked_redo:) forControlEvents:UIControlEventTouchUpInside];
     [self.propertiesBar addSubview:self.redoBtn];
+    
+    [self updatePropertiesButtonState];
 }
 
 - (void)updatePropertiesButtonState {

+ 1 - 1
compdfkit-tools/compdfkit-tools/Common/Views/PDFPopMenu/CPDFPopMenu.h

@@ -16,7 +16,7 @@
 
 @protocol CPDFPopMenuDelegate <NSObject>
 
-- (void)MenuDidClosedIn:(CPDFPopMenu *)menu isClosed:(BOOL)isClosed;
+- (void)menuDidClosedIn:(CPDFPopMenu *)menu isClosed:(BOOL)isClosed;
 
 @end
 

+ 4 - 4
compdfkit-tools/compdfkit-tools/Common/Views/PDFPopMenu/CPDFPopMenu.m

@@ -82,8 +82,8 @@
         [self.backgroundContainer addSubview:self.contentView];
     }
     
-    if(self.delegate && [self.delegate respondsToSelector:@selector(MenuDidClosedIn:isClosed:)]) {
-        [self.delegate MenuDidClosedIn:self isClosed:NO];
+    if(self.delegate && [self.delegate respondsToSelector:@selector(menuDidClosedIn:isClosed:)]) {
+        [self.delegate menuDidClosedIn:self isClosed:NO];
     }
 }
 
@@ -95,8 +95,8 @@
 
     [self removeFromSuperview];
     
-    if(self.delegate && [self.delegate respondsToSelector:@selector(MenuDidClosedIn:isClosed:)]) {
-        [self.delegate MenuDidClosedIn:self isClosed:YES];
+    if(self.delegate && [self.delegate respondsToSelector:@selector(menuDidClosedIn:isClosed:)]) {
+        [self.delegate menuDidClosedIn:self isClosed:YES];
     }
 }
 

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

@@ -19,6 +19,10 @@
 
 @implementation CPDFListView (Annotation)
 
+- (BOOL)canBecomeFirstResponder{
+    return YES;
+}
+
 #pragma mark - Private method
 
 - (UIImage *)compressImage:(UIImage *)image size:(CGSize)size {
@@ -154,8 +158,8 @@
     CGRect bounds = annotation.bounds;
     bounds = CGRectInset(bounds, -15, -15);
     CGRect rect = [self convertRect:bounds fromPage:annotation.page];
-    [self becomeFirstResponder];
     [UIMenuController sharedMenuController].menuItems = menuItems;
+    [self becomeFirstResponder];
     if (@available(iOS 13.0, *)) {
         [[UIMenuController sharedMenuController] showMenuFromView:self rect:rect];
     } else {

+ 1 - 1
viewer-ctrl-demo/viewer-ctrl-demo/CPDFViewController.m

@@ -328,7 +328,7 @@
 }
 
 #pragma mark - CPDFPopMenuDelegate
-- (void)MenuDidClosedIn:(CPDFPopMenu *)menu isClosed:(BOOL)isClosed {
+- (void)menuDidClosedIn:(CPDFPopMenu *)menu isClosed:(BOOL)isClosed {
     self.popMenuClosed = isClosed;
 }
 #pragma mark - CPDFThumbnailViewControllerDelegate