Parcourir la source

PDFView(ios) - 添加菜单

yangliuhua il y a 2 ans
Parent
commit
2567a28e17

+ 12 - 0
PDFViewer.xcodeproj/project.pbxproj

@@ -7,6 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		C96D13932924793800CC92C7 /* btn_more.png in Resources */ = {isa = PBXBuildFile; fileRef = C96D13922924793800CC92C7 /* btn_more.png */; };
 		EC3198782922593A008E0889 /* ComPDFKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EC31987629225931008E0889 /* ComPDFKit.framework */; };
 		EC3198792922593A008E0889 /* ComPDFKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EC31987629225931008E0889 /* ComPDFKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 		EC62978E29220F8300D339EE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EC62978D29220F8300D339EE /* AppDelegate.m */; };
@@ -36,6 +37,7 @@
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
+		C96D13922924793800CC92C7 /* btn_more.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = btn_more.png; sourceTree = "<group>"; };
 		EC31987629225931008E0889 /* ComPDFKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ComPDFKit.framework; sourceTree = "<group>"; };
 		EC62978929220F8300D339EE /* PDFViewer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PDFViewer.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		EC62978C29220F8300D339EE /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -69,6 +71,14 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		C96D13912924791E00CC92C7 /* Images */ = {
+			isa = PBXGroup;
+			children = (
+				C96D13922924793800CC92C7 /* btn_more.png */,
+			);
+			path = Images;
+			sourceTree = "<group>";
+		};
 		EC62978029220F8300D339EE = {
 			isa = PBXGroup;
 			children = (
@@ -126,6 +136,7 @@
 		EC6297B52922393F00D339EE /* Controller */ = {
 			isa = PBXGroup;
 			children = (
+				C96D13912924791E00CC92C7 /* Images */,
 				EC6297BB292239C200D339EE /* CPDFListController.h */,
 				EC6297BC292239C200D339EE /* CPDFListController.m */,
 				ECC8831B2923352B00F6392E /* CPDFViewController.h */,
@@ -192,6 +203,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				EC62979C29220F8400D339EE /* LaunchScreen.storyboard in Resources */,
+				C96D13932924793800CC92C7 /* btn_more.png in Resources */,
 				EC62979929220F8400D339EE /* Assets.xcassets in Resources */,
 				EC62979729220F8300D339EE /* Main.storyboard in Resources */,
 			);

+ 14 - 5
PDFViewer/Base.lproj/Main.storyboard

@@ -1,24 +1,33 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
+    <device id="retina6_0" orientation="portrait" appearance="light"/>
     <dependencies>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
         <!--View Controller-->
         <scene sceneID="tne-QT-ifu">
             <objects>
-                <viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
+                <viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
-                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                        <rect key="frame" x="0.0" y="0.0" width="390" height="844"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                        <color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
                         <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
+                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                     </view>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
             </objects>
+            <point key="canvasLocation" x="55" y="-34"/>
         </scene>
     </scenes>
+    <resources>
+        <systemColor name="systemBackgroundColor">
+            <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+        </systemColor>
+    </resources>
 </document>

+ 26 - 2
PDFViewer/Controller/CPDFViewController.m

@@ -7,9 +7,10 @@
 
 
 #import <ComPDFKit/ComPDFKit.h>
+#import <ComPDFKit/CPDFHeaderFooter.h>
 #import "CPDFViewController.h"
 
-@interface CPDFViewController ()
+@interface CPDFViewController () <UIActionSheetDelegate>
 
 @end
 
@@ -25,12 +26,35 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     // Do any additional setup after loading the view.
+    //add UIBarButtonItem in Navigation
+    self.navigationController.toolbarHidden = NO;
+    UIImage *btnMore = [UIImage imageNamed:@"btn_more"];
+    UIBarButtonItem *ringhtBarItem = [[UIBarButtonItem alloc] initWithImage:btnMore style:UIBarButtonItemStylePlain target:self action:@selector(onClickedOkbtn)];
+    self.navigationItem.rightBarButtonItem = ringhtBarItem;
+    //setting URL
     NSURL *url = [NSURL fileURLWithPath:_path];
     CPDFDocument *document = [[CPDFDocument alloc] initWithURL:url];
     CPDFView *pdfView = [[CPDFView alloc] initWithFrame:self.view.bounds];
     pdfView.document = document;
     pdfView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
-    [self.view addSubview:pdfView];
+   [self.view addSubview:pdfView];
+}
+
+- (void)onClickedOkbtn {
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
+    UIAlertAction *addWatermarkAction = [UIAlertAction actionWithTitle:@"Add Watermark" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            NSLog(@"addWatermarkAction");
+        }];
+    UIAlertAction *addHeaderfooterAction = [UIAlertAction actionWithTitle:@"Add Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            NSLog(@"addHeaderfooterAction");
+        }];
+    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+            NSLog(@"Cancel Action");
+        }];
+    [alertController addAction:addWatermarkAction];
+    [alertController addAction:addHeaderfooterAction];
+    [alertController addAction:cancelAction];
+    [self presentViewController:alertController animated:YES completion:nil];
 }
 
 @end