Browse Source

PDFEdit(iOS) - 添加右键菜单

chenyu 1 year ago
parent
commit
ddfdc78507

+ 10 - 0
Edit-Ctrl-Demo/Edit-Ctrl-Demo.xcodeproj/project.pbxproj

@@ -24,6 +24,7 @@
 		4F17C0A229F5079500445550 /* Form_Widgets_Test.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4F17C09E29F5079500445550 /* Form_Widgets_Test.pdf */; };
 		4F17C0A329F5079500445550 /* PDF32000_2008.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4F17C09F29F5079500445550 /* PDF32000_2008.pdf */; };
 		4F17C0A529F5079500445550 /* Quick Start Guide.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4F17C0A129F5079500445550 /* Quick Start Guide.pdf */; };
+		4F4CF4552A051C4D000B2062 /* CPDFListView+Event.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F4CF4532A051C4D000B2062 /* CPDFListView+Event.m */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXCopyFilesBuildPhase section */
@@ -65,6 +66,8 @@
 		4F17C09E29F5079500445550 /* Form_Widgets_Test.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = Form_Widgets_Test.pdf; sourceTree = "<group>"; };
 		4F17C09F29F5079500445550 /* PDF32000_2008.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = PDF32000_2008.pdf; sourceTree = "<group>"; };
 		4F17C0A129F5079500445550 /* Quick Start Guide.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = "Quick Start Guide.pdf"; sourceTree = "<group>"; };
+		4F4CF4532A051C4D000B2062 /* CPDFListView+Event.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CPDFListView+Event.m"; sourceTree = "<group>"; };
+		4F4CF4542A051C4D000B2062 /* CPDFListView+Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CPDFListView+Event.h"; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -109,6 +112,8 @@
 				4F17C06829F4FBFD00445550 /* SceneDelegate.m */,
 				4F17C07E29F4FE1700445550 /* CPDFViewController.h */,
 				4F17C07D29F4FE1700445550 /* CPDFViewController.m */,
+				4F4CF4542A051C4D000B2062 /* CPDFListView+Event.h */,
+				4F4CF4532A051C4D000B2062 /* CPDFListView+Event.m */,
 				4F17C06D29F4FBFD00445550 /* Main.storyboard */,
 				4F17C07029F4FBFF00445550 /* Assets.xcassets */,
 				4F17C07229F4FBFF00445550 /* LaunchScreen.storyboard */,
@@ -238,6 +243,7 @@
 			files = (
 				4F17C06629F4FBFD00445550 /* AppDelegate.m in Sources */,
 				4F17C07F29F4FE1700445550 /* CPDFViewController.m in Sources */,
+				4F4CF4552A051C4D000B2062 /* CPDFListView+Event.m in Sources */,
 				4F17C08F29F4FEE800445550 /* XMLParseManager.m in Sources */,
 				4F17C08E29F4FEE800445550 /* XPDXMLElement.m in Sources */,
 				4F17C07729F4FBFF00445550 /* main.m in Sources */,
@@ -388,6 +394,8 @@
 				"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = "Edit-Ctrl-Demo/Info.plist";
+				INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = "";
+				INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "";
 				INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
 				INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
 				INFOPLIST_KEY_UIMainStoryboardFile = Main;
@@ -417,6 +425,8 @@
 				"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = "Edit-Ctrl-Demo/Info.plist";
+				INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = "";
+				INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "";
 				INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
 				INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
 				INFOPLIST_KEY_UIMainStoryboardFile = Main;

+ 18 - 4
Edit-Ctrl-Demo/Edit-Ctrl-Demo/CPDFListView+Event.h

@@ -8,11 +8,26 @@
 //  Please see License for details. This notice may not be removed from this file.
 //
 
-#import "PDFListView.h"
+#import <compdfkit_tools/CPDFListView.h>
+#import <ComPDFKit/ComPDFKit.h>
 
-NS_ASSUME_NONNULL_BEGIN
+@interface CPDFEditArea (Editing)
 
-@interface PDFListView (Event)<UINavigationControllerDelegate,UIImagePickerControllerDelegate>
+- (BOOL)IsImageArea;
+
+@end
+
+#pragma mark - CPDFEditImageArea
+
+@interface CPDFEditImageArea : CPDFEditArea
+
+@property (nonatomic,readonly) CGRect cropRect;
+@property (nonatomic,assign)   BOOL isCropMode;
+
+@end
+
+
+@interface CPDFListView (Event)<UINavigationControllerDelegate,UIImagePickerControllerDelegate>
 
 @property(nonatomic,assign)CGPoint mPoint;
 
@@ -20,4 +35,3 @@ NS_ASSUME_NONNULL_BEGIN
 
 @end
 
-NS_ASSUME_NONNULL_END

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

@@ -139,6 +139,11 @@
 - (void)PDFViewCurrentPageDidChanged:(CPDFView *)pdfView {
 }
 
+- (void)PDFViewCustomMenuClick:(CPDFListView *)pdfView identifier:(NSString *)menuIdentifier {
+    self.editMode = CPDFEditModeText;
+    [self showMenuList];
+}
+
 #pragma mark - CPDFEditToolBarDelegate
 - (void)editClickInToolBar:(CPDFEditToolBar *)toolBar editMode:(CPDFEditMode)mode{
     self.editMode = mode;
@@ -173,9 +178,13 @@
 }
 
 - (void)propertyEditDidClickInToolBar:(CPDFEditToolBar *)toolBar{
+    [self showMenuList];
+}
+
+- (void)showMenuList {
     _baseVC = [[CPDFEditViewController alloc] initWithPDFView:self.pdfListView];
     _baseVC.editMode = self.editMode;
-    if(self.editMode == CPDFEditModeText || self.editMode == CPDFEditModeImage){
+    if((self.editMode == CPDFEditModeText || self.editMode == CPDFEditModeImage) && self.pdfListView.editStatus != CEditingSelectStateEmpty){
         
         AAPLCustomPresentationController *presentationController NS_VALID_UNTIL_END_OF_SCOPE;