Browse Source

PDFView(ios) - 修改第一版

yangliuhua 2 years ago
parent
commit
440874650f
29 changed files with 275 additions and 533 deletions
  1. 2 20
      PDFViewer.xcodeproj/project.pbxproj
  2. BIN
      PDFViewer.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile_2.xcuserdatad/UserInterfaceState.xcuserstate
  3. 4 52
      PDFViewer.xcodeproj/xcuserdata/kdanmobile_2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  4. 2 6
      PDFViewer/Controller/CPDFBatesAddViewController.h
  5. 64 31
      PDFViewer/Controller/CPDFBatesAddViewController.m
  6. 4 0
      PDFViewer/Controller/CPDFBatesDeleteViewController.m
  7. 0 26
      PDFViewer/Controller/CPDFBatesSettingController.h
  8. 0 52
      PDFViewer/Controller/CPDFBatesSettingController.m
  9. 16 24
      PDFViewer/Controller/CPDFHeaderFooterAddController.h
  10. 57 29
      PDFViewer/Controller/CPDFHeaderFooterAddController.m
  11. 0 1
      PDFViewer/Controller/CPDFHeaderFooterAddView.h
  12. 8 6
      PDFViewer/Controller/CPDFHeaderFooterAddView.m
  13. 0 29
      PDFViewer/Controller/CPDFHeaderFooterSettingController.h
  14. 0 56
      PDFViewer/Controller/CPDFHeaderFooterSettingController.m
  15. 108 56
      PDFViewer/Controller/CPDFViewController.m
  16. 0 0
      PDFViewer/Controller/Model/CPDFBatesModel.h
  17. 0 0
      PDFViewer/Controller/Model/CPDFBatesModel.m
  18. 0 0
      PDFViewer/Controller/Model/CPDFFontNameModel.h
  19. 0 0
      PDFViewer/Controller/Model/CPDFFontNameModel.m
  20. 0 0
      PDFViewer/Controller/Model/CPDFHeaderFooterModel.h
  21. 0 0
      PDFViewer/Controller/Model/CPDFHeaderFooterModel.m
  22. 0 0
      PDFViewer/Controller/Model/CPDFModel.h
  23. 0 0
      PDFViewer/Controller/Model/CPDFModel.m
  24. 0 0
      PDFViewer/Controller/Model/CPDFPageFomatModel.h
  25. 0 0
      PDFViewer/Controller/Model/CPDFPageFomatModel.m
  26. 6 6
      PDFViewer/View/CPDFBatesAddView.m
  27. 0 31
      PDFViewer/View/CPDFDropDownView.h
  28. 0 99
      PDFViewer/View/CPDFDropDownView.m
  29. 4 9
      PDFViewer/View/CPDFHeaderFooterTextTableView.m

+ 2 - 20
PDFViewer.xcodeproj/project.pbxproj

@@ -15,14 +15,11 @@
 		C96D13992924E09300CC92C7 /* CPDFHeaderFooterAddView.m in Sources */ = {isa = PBXBuildFile; fileRef = C96D13982924E09300CC92C7 /* CPDFHeaderFooterAddView.m */; };
 		C993B8FB2925E14000D8F474 /* text_color_bar.png in Resources */ = {isa = PBXBuildFile; fileRef = C993B8FA2925E14000D8F474 /* text_color_bar.png */; };
 		C993B8FE2925E52800D8F474 /* CPDFHeaderFooterDeleteController.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B8FD2925E52800D8F474 /* CPDFHeaderFooterDeleteController.m */; };
-		C993B90229264DC900D8F474 /* CPDFBatesSettingController.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B90129264DC900D8F474 /* CPDFBatesSettingController.m */; };
 		C993B9042926541D00D8F474 /* add_newpage01.png in Resources */ = {isa = PBXBuildFile; fileRef = C993B9032926541D00D8F474 /* add_newpage01.png */; };
 		C993B9062926543500D8F474 /* pageedit_delete.png in Resources */ = {isa = PBXBuildFile; fileRef = C993B9052926543500D8F474 /* pageedit_delete.png */; };
 		C993B909292654BE00D8F474 /* CPDFBatesDeleteViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B908292654BE00D8F474 /* CPDFBatesDeleteViewController.m */; };
 		C993B90C29271FCA00D8F474 /* CPDFBatesAddViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B90B29271FCA00D8F474 /* CPDFBatesAddViewController.m */; };
 		C993B90F2927200400D8F474 /* CPDFBatesAddView.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B90E2927200400D8F474 /* CPDFBatesAddView.m */; };
-		C993B912292B07F600D8F474 /* CPDFHeaderFooterSettingController.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B911292B07F600D8F474 /* CPDFHeaderFooterSettingController.m */; };
-		C993B915292B1C4100D8F474 /* CPDFDropDownView.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B914292B1C4100D8F474 /* CPDFDropDownView.m */; };
 		C993B918292B5BC500D8F474 /* CPDFHeaderFooterModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B917292B5BC500D8F474 /* CPDFHeaderFooterModel.m */; };
 		C9E65160292CBC31001B2C9D /* MASViewConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E65146292CBC2F001B2C9D /* MASViewConstraint.m */; };
 		C9E65161292CBC31001B2C9D /* NSLayoutConstraint+MASDebugAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E65148292CBC2F001B2C9D /* NSLayoutConstraint+MASDebugAdditions.m */; };
@@ -75,8 +72,6 @@
 		C993B8FA2925E14000D8F474 /* text_color_bar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = text_color_bar.png; sourceTree = "<group>"; };
 		C993B8FC2925E52800D8F474 /* CPDFHeaderFooterDeleteController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFHeaderFooterDeleteController.h; sourceTree = "<group>"; };
 		C993B8FD2925E52800D8F474 /* CPDFHeaderFooterDeleteController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFHeaderFooterDeleteController.m; sourceTree = "<group>"; };
-		C993B90029264DC900D8F474 /* CPDFBatesSettingController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFBatesSettingController.h; sourceTree = "<group>"; };
-		C993B90129264DC900D8F474 /* CPDFBatesSettingController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFBatesSettingController.m; sourceTree = "<group>"; };
 		C993B9032926541D00D8F474 /* add_newpage01.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = add_newpage01.png; sourceTree = "<group>"; };
 		C993B9052926543500D8F474 /* pageedit_delete.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pageedit_delete.png; sourceTree = "<group>"; };
 		C993B907292654BE00D8F474 /* CPDFBatesDeleteViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFBatesDeleteViewController.h; sourceTree = "<group>"; };
@@ -85,10 +80,6 @@
 		C993B90B29271FCA00D8F474 /* CPDFBatesAddViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFBatesAddViewController.m; sourceTree = "<group>"; };
 		C993B90D2927200400D8F474 /* CPDFBatesAddView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFBatesAddView.h; sourceTree = "<group>"; };
 		C993B90E2927200400D8F474 /* CPDFBatesAddView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFBatesAddView.m; sourceTree = "<group>"; };
-		C993B910292B07F600D8F474 /* CPDFHeaderFooterSettingController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFHeaderFooterSettingController.h; sourceTree = "<group>"; };
-		C993B911292B07F600D8F474 /* CPDFHeaderFooterSettingController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFHeaderFooterSettingController.m; sourceTree = "<group>"; };
-		C993B913292B1C4100D8F474 /* CPDFDropDownView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFDropDownView.h; sourceTree = "<group>"; };
-		C993B914292B1C4100D8F474 /* CPDFDropDownView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFDropDownView.m; sourceTree = "<group>"; };
 		C993B916292B5BC500D8F474 /* CPDFHeaderFooterModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFHeaderFooterModel.h; sourceTree = "<group>"; };
 		C993B917292B5BC500D8F474 /* CPDFHeaderFooterModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFHeaderFooterModel.m; sourceTree = "<group>"; };
 		C9E65146292CBC2F001B2C9D /* MASViewConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASViewConstraint.m; sourceTree = "<group>"; };
@@ -227,7 +218,6 @@
 			children = (
 				C9E65145292CBBDE001B2C9D /* Masonry */,
 				EC6297B52922393F00D339EE /* Controller */,
-				EC6297AD29222D3100D339EE /* Model */,
 				EC6297AE29222D4400D339EE /* View */,
 				EC62978C29220F8300D339EE /* AppDelegate.h */,
 				EC62978D29220F8300D339EE /* AppDelegate.m */,
@@ -255,8 +245,8 @@
 				C9E6516C292F4EB5001B2C9D /* CPDFBatesModel.m */,
 				C9E6517129308A6C001B2C9D /* CPDFPageFomatModel.h */,
 				C9E6517229308A6C001B2C9D /* CPDFPageFomatModel.m */,
-				C94D478A29344878008983FB /* CPDFFontNameModel.h */,
 				C94D478B29344878008983FB /* CPDFFontNameModel.m */,
+				C94D478A29344878008983FB /* CPDFFontNameModel.h */,
 			);
 			path = Model;
 			sourceTree = "<group>";
@@ -269,8 +259,6 @@
 				C96D13982924E09300CC92C7 /* CPDFHeaderFooterAddView.m */,
 				C993B90D2927200400D8F474 /* CPDFBatesAddView.h */,
 				C993B90E2927200400D8F474 /* CPDFBatesAddView.m */,
-				C993B913292B1C4100D8F474 /* CPDFDropDownView.h */,
-				C993B914292B1C4100D8F474 /* CPDFDropDownView.m */,
 				C9E6516E29306274001B2C9D /* CPDFHeaderFooterTextTableView.h */,
 				C9E6516F29306274001B2C9D /* CPDFHeaderFooterTextTableView.m */,
 			);
@@ -289,14 +277,11 @@
 				C96D13952924DD7E00CC92C7 /* CPDFHeaderFooterAddController.m */,
 				C993B8FC2925E52800D8F474 /* CPDFHeaderFooterDeleteController.h */,
 				C993B8FD2925E52800D8F474 /* CPDFHeaderFooterDeleteController.m */,
-				C993B90029264DC900D8F474 /* CPDFBatesSettingController.h */,
-				C993B90129264DC900D8F474 /* CPDFBatesSettingController.m */,
 				C993B907292654BE00D8F474 /* CPDFBatesDeleteViewController.h */,
 				C993B908292654BE00D8F474 /* CPDFBatesDeleteViewController.m */,
 				C993B90A29271FCA00D8F474 /* CPDFBatesAddViewController.h */,
 				C993B90B29271FCA00D8F474 /* CPDFBatesAddViewController.m */,
-				C993B910292B07F600D8F474 /* CPDFHeaderFooterSettingController.h */,
-				C993B911292B07F600D8F474 /* CPDFHeaderFooterSettingController.m */,
+				EC6297AD29222D3100D339EE /* Model */,
 			);
 			path = Controller;
 			sourceTree = "<group>";
@@ -376,7 +361,6 @@
 			buildActionMask = 2147483647;
 			files = (
 				C96D13992924E09300CC92C7 /* CPDFHeaderFooterAddView.m in Sources */,
-				C993B915292B1C4100D8F474 /* CPDFDropDownView.m in Sources */,
 				ECC8831D2923352B00F6392E /* CPDFViewController.m in Sources */,
 				C993B918292B5BC500D8F474 /* CPDFHeaderFooterModel.m in Sources */,
 				C9E65169292CBC31001B2C9D /* MASCompositeConstraint.m in Sources */,
@@ -394,10 +378,8 @@
 				C9E6516D292F4EB5001B2C9D /* CPDFBatesModel.m in Sources */,
 				C9E65160292CBC31001B2C9D /* MASViewConstraint.m in Sources */,
 				C94D478C29344878008983FB /* CPDFFontNameModel.m in Sources */,
-				C993B90229264DC900D8F474 /* CPDFBatesSettingController.m in Sources */,
 				C9E65168292CBC31001B2C9D /* MASLayoutConstraint.m in Sources */,
 				C993B90F2927200400D8F474 /* CPDFBatesAddView.m in Sources */,
-				C993B912292B07F600D8F474 /* CPDFHeaderFooterSettingController.m in Sources */,
 				EC62978E29220F8300D339EE /* AppDelegate.m in Sources */,
 				EC62979F29220F8400D339EE /* main.m in Sources */,
 				C9E6517029306274001B2C9D /* CPDFHeaderFooterTextTableView.m in Sources */,

BIN
PDFViewer.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile_2.xcuserdatad/UserInterfaceState.xcuserstate


+ 4 - 52
PDFViewer.xcodeproj/xcuserdata/kdanmobile_2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -56,7 +56,7 @@
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
             uuid = "A2F734DB-C4C5-43E0-89EA-C26301A35044"
-            shouldBeEnabled = "Yes"
+            shouldBeEnabled = "No"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "PDFViewer/Controller/CPDFTableViewController.m"
@@ -68,66 +68,18 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "45C57A90-3108-43A0-83DA-9CC4CA96B230"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDFViewer/Controller/CPDFViewController.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "107"
-            endingLineNumber = "107"
-            landmarkName = "-getHeaderFooterModel:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "9FF7B441-2E54-48D4-8E11-733544F682A3"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDFViewer/Controller/CPDFViewController.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "149"
-            endingLineNumber = "149"
-            landmarkName = "-getBatesMdel:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "347FADD6-093D-4A56-B336-B2D06A9DFE56"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDFViewer/Controller/CPDFViewController.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "188"
-            endingLineNumber = "188"
-            landmarkName = "-deleteBates:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
             uuid = "05E074D4-C1BE-4457-B3CC-04110F45C96C"
-            shouldBeEnabled = "Yes"
+            shouldBeEnabled = "No"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "PDFViewer/Controller/CPDFBatesAddViewController.m"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "144"
-            endingLineNumber = "144"
+            startingLineNumber = "163"
+            endingLineNumber = "163"
             landmarkName = "-changeText:"
             landmarkType = "7">
          </BreakpointContent>

+ 2 - 6
PDFViewer/Controller/CPDFBatesAddViewController.h

@@ -14,17 +14,13 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-@interface CPDFBatesAddViewController : UIViewController <UITableViewDelegate,UITableViewDataSource>
+@interface CPDFBatesAddViewController : UIViewController <UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>
 
-- (void)cancelClick:(UIBarButtonItem *)btn;
 - (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size;
-- (void)changeLocation:(UISegmentedControl *)sender;
-- (void)changeAligbment:(UISegmentedControl *)sender;
-- (void)sliderChange:(UISlider *)slider;
 
 @property (nonatomic,strong) UIImage *image;
 @property (nonatomic,assign) CGSize size;
-@property (nonatomic,assign) Position position;
+@property (nonatomic,assign) PositionRec position;
 @property (nonatomic,strong) CPDFBatesAddView *batesAddView;
 @property (nonatomic,strong) UILabel *showLabel;
 @property (nonatomic,strong) UIImageView *imageView;

+ 64 - 31
PDFViewer/Controller/CPDFBatesAddViewController.m

@@ -29,13 +29,15 @@
     self.navigationController.toolbarHidden = YES;
     self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneBatesClick:)];
     self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelClick:)];
-    //initialize model
+    
+    // Initialize model
     _modelBatesData = [[CPDFBatesModel alloc] init];
     _modelBatesData.fontName = @"Helvetica";
     _modelBatesData.fontPosition = 1;
     _modelBatesData.fontText = @"#2#1#0#0";
     _modelBatesData.fontColor = [UIColor blackColor];
-    //add page image
+    
+    // Add page image
     _imageView = [[UIImageView alloc] init];
     _imageView.image = self.image;
     CALayer *layer = [_imageView layer];
@@ -51,7 +53,7 @@
         make.height.mas_equalTo(self.size.height/3);
     }];
     
-    //add view
+    // Add view
     [self.batesAddView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(self.imageView.mas_bottom).offset(60);
         make.left.equalTo(self.view.mas_left);
@@ -59,22 +61,23 @@
         make.height.mas_equalTo(self.view.frame.size.height);
     }];
     
-    //UI event
+    // UI event
     [ _batesAddView.localSegment addTarget:self action:@selector(changeLocation:) forControlEvents:UIControlEventValueChanged];
     [ _batesAddView.aligbmentSegment addTarget:self action:@selector(changeAligbment:) forControlEvents:UIControlEventValueChanged];
     [ _batesAddView.colorSlider addTarget:self action:@selector(sliderChange:) forControlEvents:UIControlEventValueChanged];
     [_batesAddView.pageIndexNumberText addTarget:self action:@selector(changePageStart:) forControlEvents:UIControlEventEditingChanged];
     [_batesAddView.pageNumberText addTarget:self action:@selector(changeText:) forControlEvents:UIControlEventEditingChanged];
-    [_batesAddView.fontNameText addTarget:self action:@selector(changeTableView:) forControlEvents:UIControlEventEditingDidBegin];
+    
+    _batesAddView.fontNameText.delegate = self;
 }
 
-#pragma mark - CPDFHeaderFooterTextTableView's initialize
+#pragma mark - Accessors
 
-//tableView initialize
 - (NSArray *)dataArray {
     if (!_dataArray) {
         _dataArray = [NSMutableArray array];
         NSArray *fontNameArray = [[NSArray alloc] initWithObjects:@"Helvetica",@"Arial",@"Arial Rounded MT Bold", @"Arial Unicode MS",@"Courier",nil];
+        
         for (int i = 0; i < fontNameArray.count; i++) {
             CPDFFontNameModel *fontNameModel = [[CPDFFontNameModel alloc] init];
             fontNameModel.fontName = fontNameArray[i];
@@ -84,10 +87,14 @@
     return _dataArray;
 }
 
-- (void)changeTableView:(UITextField *)text {
+#pragma mark - UITextFieldDelegate
+
+- (void)textFieldDidBeginEditing:(UITextField *)textField {
     _fontName = [[CPDFHeaderFooterTextTableView alloc] initWithTitleName:@"Font Name"];
+    
     _fontName.tableView.delegate = self;
     _fontName.tableView.dataSource = self;
+    
     [self.batesAddView addSubview:self.fontName ];
     [self.view bringSubviewToFront:self.fontName];
     [_fontName mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -96,13 +103,16 @@
         make.width.mas_equalTo(293);
         make.height.mas_equalTo(300);
     }];
+    
     [self.fontName.okBtn addTarget:self action:@selector(fontNameOk:) forControlEvents:UIControlEventTouchUpInside];
 }
 
-- (void)fontNameOk:(UIButton *)okBtn {
-    [_fontName removeFromSuperview];
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
+    return  NO;
 }
 
+#pragma mark - UITableViewDataSource
+
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
     return self.dataArray.count;
 }
@@ -112,19 +122,24 @@
     if (cell == nil) {
         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"pageFormat"];
     }
+    
     cell.textLabel.text = [self.dataArray[indexPath.row] fontName];
     return cell;
 }
 
+#pragma mark - UITableViewDelegate
+
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     self.batesAddView.fontNameText.text = [self.dataArray[indexPath.row] fontName];
+    
     self.modelBatesData.fontName = [self.dataArray[indexPath.row] fontName];
+    
     self.showLabel.font = [UIFont fontWithName:[self.dataArray[indexPath.row] fontName] size:5];
 }
 
-#pragma mark - done and cancel in CPDFbatesAddViewController's navigationItem
+#pragma mark - Actions
 
-//done button enable
+// Done button enable
 - (void)doneBatesClick:(UIBarButtonItem *)btn {
     NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:self.modelBatesData,@"batesModel", nil];
     NSNotification *notification = [NSNotification notificationWithName:@"getAddBatesModel" object:nil userInfo:dict];
@@ -132,34 +147,50 @@
     [self.navigationController popViewControllerAnimated:YES];
 }
 
-//candel button enable
+// Candel button enable
 - (void)cancelClick:(UIBarButtonItem *)btn {
     [self.navigationController popViewControllerAnimated:YES];
 }
 
-#pragma mark - model get value from UI
+- (void)fontNameOk:(UIButton *)okBtn {
+    [_fontName removeFromSuperview];
+}
 
-//get page text for bates's model
+#pragma mark - UI Actions
+
+// Get page text for bates's model
 - (void)changeText:(UITextField *)text {
     NSArray *textArray = [text.text componentsSeparatedByString:@"#"];
     NSString *showText = [[NSString alloc] init];
-    int i = 0;
-    while (i < textArray.count) {
-        NSString *test = showText;
-        showText = [NSString stringWithFormat:@"%@%@",test,textArray[i]];
-        i++;
+    
+    if (text.text.length >= 2) {
+        int i = [textArray[1] intValue];
+        for (int j = 0; j < i-1; j++) {
+            NSString *test = showText;
+            showText = [NSString stringWithFormat:@"%d%@",0,test];
+        }
     }
+    if (text.text.length >= 4) {
+        showText = [NSString stringWithFormat:@"%@%@",showText,textArray[2]];
+    }
+    if (text.text.length >= 6) {
+        showText = [NSString stringWithFormat:@"%@%@",textArray[3],showText];
+    }
+    if (text.text.length == 8) {
+        showText = [NSString stringWithFormat:@"%@%@",showText,textArray[4]];
+    }
+    
     self.showLabel.text = showText;
     self.modelBatesData.fontText = text.text;
 }
 
-//get page text start for bates's model
+// Get page text start for bates's model
 - (void)changePageStart:(UITextField *)text {
     int start = [text.text intValue];
     self.modelBatesData.pageStart = [NSString stringWithFormat:@"%d",start - 1];
 }
 
-//slider select color
+// Slider select color
 - (void)sliderChange:(UISlider *)slider {
     switch ((int)slider.value / 10) {
         case 0:
@@ -171,8 +202,8 @@
             self.modelBatesData.fontColor = [UIColor orangeColor];
             break;
         case 2:
-            self.showLabel.textColor = [UIColor colorWithRed:239.0 / 255 green:140.0/255 blue:133.0 / 255 alpha:1];
-            self.modelBatesData.fontColor = [UIColor colorWithRed:239.0 / 255 green:140.0/255 blue:133.0 / 255 alpha:1];
+            self.showLabel.textColor = [UIColor colorWithRed:239.0 / 255 green:140.0 / 255 blue:133.0 / 255 alpha:1];
+            self.modelBatesData.fontColor = [UIColor colorWithRed:239.0 / 255 green:140.0 / 255 blue:133.0 / 255 alpha:1];
             break;
         case 3:
             self.showLabel.textColor = [UIColor yellowColor];
@@ -203,7 +234,7 @@
     }
 }
 
-//select headerfooter
+// Select headerfooter
 - (void)changeLocation:(UISegmentedControl *)sender {
     if (sender.selectedSegmentIndex == 0) {
         _position.location = kHeader;
@@ -213,7 +244,7 @@
     [self showPages];
 }
 
-//select aligment
+// Select aligment
 - (void)changeAligbment:(UISegmentedControl *)sender {
     if (sender.selectedSegmentIndex == 0) {
         _position.aligment = kLeft;
@@ -225,7 +256,7 @@
     [self showPages];
 }
 
-//show headerfooter and aligment
+// Show headerfooter and aligment
 - (void)showPages {
     if (_showLabel == nil) {
         _showLabel = [[UILabel alloc] init];
@@ -233,6 +264,7 @@
     [_showLabel setText:@"2100"];
     _showLabel.font = [UIFont systemFontOfSize:5];
     [self.imageView addSubview:self.showLabel];
+    
     switch (self.position.location) {
         case kHeader:
             if (self.position.aligment == kLeft) {
@@ -261,6 +293,7 @@
                 self.modelBatesData.fontPosition = 2;
             }
             break;
+            
         case kFooter:
             if (self.position.aligment == kLeft) {
                 [_showLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
@@ -293,9 +326,9 @@
     }
 }
 
-#pragma mark - when orientation
+#pragma mark - Orientation
 
-//when orientation
+// When orientation
 - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
     if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) {
         [_imageView mas_remakeConstraints:^(MASConstraintMaker *make) {
@@ -304,7 +337,7 @@
             make.width.mas_equalTo(self.size.width / 3);
             make.height.mas_equalTo(self.size.height / 3);
         }];
-        //add view
+        
         [self.batesAddView mas_remakeConstraints:^(MASConstraintMaker *make) {
             make.top.equalTo(self.view.mas_top).offset(15);
             make.left.equalTo(self.view.mas_left).offset(self.view.frame.size.width / 2 + 200);
@@ -319,7 +352,7 @@
             make.width.mas_equalTo(self.size.width / 3);
             make.height.mas_equalTo(self.size.height / 3);
         }];
-        //add view
+        
         [self.batesAddView mas_remakeConstraints:^(MASConstraintMaker *make) {
             make.top.equalTo(self.imageView.mas_bottom).offset(60);
             make.left.equalTo(self.view.mas_left);

+ 4 - 0
PDFViewer/Controller/CPDFBatesDeleteViewController.m

@@ -17,16 +17,20 @@
     [super viewDidLoad];
     // Do any additional setup after loading the view.
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Delete Bates" message:@"Are you sure delete all Bates" preferredStyle:UIAlertControllerStyleAlert];
+    
     UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
         NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:@"1",@"deleteBates", nil];
         NSNotification *notification = [NSNotification notificationWithName:@"deleteBatesModel" object:nil userInfo:dict];
         [[NSNotificationCenter defaultCenter] postNotification:notification];
         }];
+    
     UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
         NSLog(@"Cancel Action");
         }];
+    
     [alertController addAction:okAction];
     [alertController addAction:cancelAction];
+    
     [self presentViewController:alertController animated:YES completion:nil];
 }
 

+ 0 - 26
PDFViewer/Controller/CPDFBatesSettingController.h

@@ -1,26 +0,0 @@
-//
-//  BatesSettingViewController.h
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/17.
-//
-
-#import <UIKit/UIKit.h>
-#import "CPDFBatesModel.h"
-#import "CPDFBatesDeleteViewController.h"
-#import "CPDFBatesAddViewController.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface CPDFBatesSettingController : UIViewController
-
-@property (nonatomic,strong) UIImage *image;
-@property (nonatomic,assign) CGSize size;
-@property (nonatomic,strong) CPDFBatesModel *modelBatesData;
-@property (nonatomic,strong) CPDFBatesAddViewController *batesAddControl;
-
-- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size;
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 52
PDFViewer/Controller/CPDFBatesSettingController.m

@@ -1,52 +0,0 @@
-//
-//  BatesSettingViewController.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/17.
-//
-
-#import "CPDFBatesSettingController.h"
-
-@interface CPDFBatesSettingController ()
-
-@end
-
-@implementation CPDFBatesSettingController
-
-- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size {
-    self = [super init];
-    if (self) {
-        _image = image;
-        _size  = size;
-    }
-    return self;
-}
-
-- (void)viewDidLoad {
-    [super viewDidLoad];
-    // Do any additional setup after loading the view.
-    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
-    UIAlertAction *addBatesAction = [UIAlertAction actionWithTitle:@"Add Bates" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-        self.batesAddControl = [[CPDFBatesAddViewController alloc] initWithIamge:self.image WithSize:self.size];
-        [self addChildViewController:self.batesAddControl];
-        [self.view addSubview:self.batesAddControl.view];
-        [self.navigationController pushViewController:self.batesAddControl animated:NO];
-        self.view.hidden = YES;
-        }];
-    UIAlertAction *delereBatesAction = [UIAlertAction actionWithTitle:@"Delete Bates" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-        CPDFBatesDeleteViewController *batesDeleteControl = [[CPDFBatesDeleteViewController alloc] init];
-        [self addChildViewController:batesDeleteControl];
-        [self.view addSubview:batesDeleteControl.view];
-        [self.navigationController pushViewController:batesDeleteControl animated:NO];
-        }];
-    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-            NSLog(@"Cancel Action");
-        self.view.hidden = YES;
-        }];
-    [alertController addAction:addBatesAction];
-    [alertController addAction:delereBatesAction];
-    [alertController addAction:cancelAction];
-    [self presentViewController:alertController animated:YES completion:nil];
-}
-
-@end

+ 16 - 24
PDFViewer/Controller/CPDFHeaderFooterAddController.h

@@ -16,42 +16,34 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-typedef enum Location {
+#define kFormat @"^[ ]+$"
+
+typedef enum CGLocation {
     kHeader = 0,
     kFooter,
-}Location;
+}CGLocation;
 
-typedef enum Aligment {
+typedef enum CGAligment {
     kLeft = 0,
     kCenter,
     kRinght,
-}Aligment;
-
-typedef struct Position {
-    Location location;
-    Aligment aligment;
-}Position;
-
-@interface CPDFHeaderFooterAddController : UIViewController <UITableViewDelegate,UITableViewDataSource>
-
-- (void)cancelClick:(UIBarButtonItem *)btn;
-- (void)doneClick:(UIBarButtonItem *)btn;
-- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size WithDocument:(CPDFDocument *)docment WithView:(CPDFView *) pdfView;
-- (void)changeLocation:(UISegmentedControl *)sender;
-- (void)changeAligbment:(UISegmentedControl *)sender;
-- (void)sliderChange:(UISlider *)slider;
-- (void)changeFontSize:(UITextField *)text;
-- (void)changePageStart:(UITextField *)text;
+}CGAligment;
+
+typedef struct PositionRec {
+    CGLocation location;
+    CGAligment aligment;
+}PositionRec;
+
+@interface CPDFHeaderFooterAddController : UIViewController  <UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>
+
+- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size;
  
 @property (nonatomic,assign) CGSize size;
 @property (nonatomic,strong) UIImage *image;
-@property (nonatomic,assign) Position position;
+@property (nonatomic,assign) PositionRec position;
 @property (nonatomic,strong) CPDFHeaderFooterAddView *headerFooterview;
 @property (nonatomic,strong) UILabel *showLabel;
 @property (nonatomic,strong) CPDFHeaderFooterModel *modelData;
-@property (nonatomic,strong) CPDFDocument *document;
-@property (nonatomic,strong) CPDFHeaderFooter *headerFooter;
-@property (nonatomic,strong) CPDFView *pdfView;
 @property (nonatomic,strong) UIImageView *imageView;
 @property (nonatomic,strong) CPDFHeaderFooterTextTableView *pageFormat;
 @property (nonatomic,strong) NSMutableArray *dataArray;

+ 57 - 29
PDFViewer/Controller/CPDFHeaderFooterAddController.m

@@ -13,32 +13,33 @@
 
 @implementation CPDFHeaderFooterAddController
 
-- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size WithDocument:(CPDFDocument *)docment WithView:(CPDFView *)pdfView {
+- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size {
     self = [super init];
     if (self) {
         _image = image;
         _size  = size;
-        _document = docment;
-        _pdfView = pdfView;
     }
     return self;
 }
 
 - (void)viewDidLoad { 
     [super viewDidLoad];
+    
     // Do any additional setup after loading the view.
-    //setting navigation
+    // Setting navigation
     self.navigationItem.title = @"Add Page NUmber";
     self.navigationController.toolbarHidden = YES;
     self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneClick:)];
     self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelClick:)];
-    //initialize model
+    
+    // Initialize model
     _modelData = [[CPDFHeaderFooterModel alloc] init];
     _modelData.fontSize = 18.0;
     _modelData.fontSelcet = 0;
     _modelData.fontPosition = 1;
     _modelData.pageStart = @"1";
-    //add page image
+    
+    // Add page image
     _headerFooterview = [[CPDFHeaderFooterAddView alloc] init];
     _imageView = [[UIImageView alloc] init];
     _imageView.image = self.image;
@@ -54,7 +55,7 @@
         make.height.mas_equalTo(self.size.height / 3);
     }];
     
-    //add view
+    // Add view
     [self.headerFooterview mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(self.imageView.mas_bottom).offset(60);
         make.left.equalTo(self.view.mas_left);
@@ -62,22 +63,23 @@
         make.height.mas_equalTo(self.view.frame.size.height);
     }];
     
-    //UI event
+    // UI event
     [_headerFooterview.localSegment addTarget:self action:@selector(changeLocation:) forControlEvents:UIControlEventValueChanged];
     [_headerFooterview.aligbmentSegment addTarget:self action:@selector(changeAligbment:) forControlEvents:UIControlEventValueChanged];
     [_headerFooterview.colorSlider addTarget:self action:@selector(sliderChange:) forControlEvents:UIControlEventValueChanged];
     [_headerFooterview.fontSizeText addTarget:self action:@selector(changeFontSize:) forControlEvents:UIControlEventEditingChanged];
     [_headerFooterview.pageIndexNumberText addTarget:self action:@selector(changePageStart:) forControlEvents:UIControlEventEditingChanged];
-    [_headerFooterview.pageNumberText addTarget:self action:@selector(changeTableView:) forControlEvents:UIControlEventEditingDidBegin];
+    
+    _headerFooterview.pageNumberText.delegate = self;
 }
 
-#pragma mark - CPDFHeaderFooterTextTableView's initialize
+#pragma mark - Accessors
 
-//tableView initialize
 - (NSArray *)dataArray {
     if (!_dataArray) {
         _dataArray = [NSMutableArray array];
         NSArray *pageFormatArray = [[NSArray alloc] initWithObjects:@"1",@"page 1",@"1/n",@"1 of n",@"page 1 of n",nil];
+        
         for (int i = 0; i < pageFormatArray.count; i++) {
             CPDFPageFomatModel *pageFormatMode = [[CPDFPageFomatModel alloc] init];
             pageFormatMode.pageFormat = pageFormatArray[i];
@@ -87,10 +89,15 @@
     return _dataArray;
 }
 
-- (void)changeTableView:(UITextField *)text {
+#pragma mark - UITextFieldDelegate
+
+// TableView initialize
+- (void)textFieldDidBeginEditing:(UITextField *)textField {
     _pageFormat = [[CPDFHeaderFooterTextTableView alloc] initWithTitleName:@"Page Format"];
+    
     _pageFormat.tableView.delegate = self;
     _pageFormat.tableView.dataSource = self;
+    
     [self.headerFooterview addSubview:self.pageFormat];
     [self.view bringSubviewToFront:self.pageFormat];
     [_pageFormat mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -99,14 +106,24 @@
         make.width.mas_equalTo(293);
         make.height.mas_equalTo(300);
     }];
+    
+    // Tablevire animation
+    [UIView animateWithDuration:2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
+        NSLog(@"animations");
+        self.pageFormat.center = CGPointMake(self.pageFormat.center.x + 150 + [UIScreen mainScreen].bounds.size.width / 2, self.pageFormat.center.y);
+    } completion:^(BOOL finished) {
+        NSLog(@"completion");
+    }];
+    
     [self.pageFormat.okBtn addTarget:self action:@selector(pageFormatOk:) forControlEvents:UIControlEventTouchUpInside];
 }
 
-
-- (void)pageFormatOk:(UIButton *)okBtn {
-    [self.pageFormat removeFromSuperview];
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
+    return  NO;
 }
 
+#pragma mark - UITableViewDataSource
+
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
     return self.dataArray.count;
 }
@@ -116,24 +133,29 @@
     if (cell == nil) {
         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"pageFormat"];
     }
+    
     cell.textLabel.text = [self.dataArray[indexPath.row] pageFormat];
     return cell;
 }
 
+#pragma mark - UITableViewDelegate
+
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     self.headerFooterview.pageNumberText.text = [self.dataArray[indexPath.row] pageFormat];
+    
     self.modelData.fontSelcet = indexPath.row;
+    
     self.showLabel.text = [self.dataArray[indexPath.row] pageFormat];
 }
 
-#pragma mark - done and cancel in CPDFHeaderFooterAddController's navigationItem
+#pragma mark - Actions
 
-//candel button enable
+// Candel button enable
 - (void)cancelClick:(UIBarButtonItem *)btn {
     [self.navigationController popViewControllerAnimated:YES];
 }
 
-//done button enable
+// Done button enable
 - (void)doneClick:(UIBarButtonItem *)btn {
     NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:self.modelData,@"model", nil];
     NSNotification *notification = [NSNotification notificationWithName:@"getAddHeaderFooterModel" object:nil userInfo:dict];
@@ -141,22 +163,26 @@
     [self.navigationController popViewControllerAnimated:YES];
 }
 
-#pragma mark - model get value from UI
+- (void)pageFormatOk:(UIButton *)okBtn {
+    [self.pageFormat removeFromSuperview];
+}
+
+#pragma mark - UI Actions
 
-//get page start for headerfooter's model
+// Get page start for headerfooter's Model
 - (void)changePageStart:(UITextField *)text {
     int start = [text.text intValue];
     self.modelData.pageStart = [NSString stringWithFormat:@"%d",start];
 }
 
-//get headerfoote's font size for headerfooter'model
+// Get headerfoote's font size for headerfooter's Model
 - (void)changeFontSize:(UITextField *)text {
     float size = [text.text floatValue];
     _showLabel.font = [UIFont systemFontOfSize:size / 3];
     _modelData.fontSize = size;
 }
 
-//slider select color
+// Slider select color
 - (void)sliderChange:(UISlider *)slider {
     switch ((int)slider.value / 10) {
         case 0:
@@ -204,7 +230,7 @@
     }
 }
 
-//select headerfooter
+// Select headerfooter
 - (void)changeLocation:(UISegmentedControl *)sender {
     if (sender.selectedSegmentIndex == 0) {
         _position.location = kHeader;
@@ -214,7 +240,7 @@
     [self showPages];
 }
 
-//select aligment
+// Select aligment
 - (void)changeAligbment:(UISegmentedControl *)sender {
     if (sender.selectedSegmentIndex == 0) {
         _position.aligment = kLeft;
@@ -226,7 +252,7 @@
     [self showPages];
 }
 
-//show headerfooter and aligment
+// Show headerfooter and aligment
 - (void)showPages {
     if (_showLabel == nil) {
         _showLabel = [[UILabel alloc] init];
@@ -234,6 +260,7 @@
     [_showLabel setText:@"1"];
     _showLabel.font = [UIFont systemFontOfSize:6];
     [self.imageView addSubview:self.showLabel];
+    
     switch (self.position.location) {
         case kHeader:
             if (self.position.aligment == kLeft) {
@@ -262,6 +289,7 @@
                 self.modelData.fontPosition = 2;
             }
             break;
+            
         case kFooter:
             if (self.position.aligment == kLeft) {
                 [_showLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
@@ -294,9 +322,9 @@
     }
 }
 
-#pragma mark - when orientation
+#pragma mark - Orientation
 
-//when orientation
+// When orientation
 - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
     if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) {
         [_imageView mas_remakeConstraints:^(MASConstraintMaker *make) {
@@ -305,7 +333,7 @@
             make.width.mas_equalTo(self.size.width / 3);
             make.height.mas_equalTo(self.size.height / 3);
         }];
-        //add view
+        
         [self.headerFooterview mas_remakeConstraints:^(MASConstraintMaker *make) {
             make.top.equalTo(self.view.mas_top).offset(15);
             make.left.equalTo(self.view.mas_left).offset(self.view.frame.size.width / 2 + 200);
@@ -320,7 +348,7 @@
             make.width.mas_equalTo(self.size.width / 3);
             make.height.mas_equalTo(self.size.height / 3);
         }];
-        //add view
+        
         [self.headerFooterview mas_remakeConstraints:^(MASConstraintMaker *make) {
             make.top.equalTo(self.imageView.mas_bottom).offset(60);
             make.left.equalTo(self.view.mas_left);

+ 0 - 1
PDFViewer/Controller/CPDFHeaderFooterAddView.h

@@ -6,7 +6,6 @@
 //
 
 #import <UIKit/UIKit.h>
-#import "CPDFDropDownView.h"
 
 NS_ASSUME_NONNULL_BEGIN
 

+ 8 - 6
PDFViewer/Controller/CPDFHeaderFooterAddView.m

@@ -14,7 +14,7 @@
     self = [super initWithFrame:frame];
     CGFloat offsetx = 3.5;
     if (self) {
-        //Page number location
+        // Page number location
         _localLabel = [[UILabel alloc] init];
         [_localLabel setText:@"Page number position"];
         _localLabel.font = [UIFont boldSystemFontOfSize:12];
@@ -35,7 +35,7 @@
             make.height.mas_equalTo(44);
         }];
         
-        //alignment
+        // Alignment
         _alignmentLabel = [[UILabel alloc] init];
         [_alignmentLabel setText:@"alignment"];
         _alignmentLabel.font = [UIFont boldSystemFontOfSize:12];
@@ -56,7 +56,7 @@
             make.height.mas_equalTo(44);
         }];
         
-        //font color
+        // Font color
         _colorLabel = [[UILabel alloc] init];
         [_colorLabel setText:@"Font Color"];
         _colorLabel.font = [UIFont boldSystemFontOfSize:12];
@@ -91,7 +91,7 @@
             make.height.mas_equalTo(44);
         }];
         
-        //page number
+        // Page number
         _pageNumberLabel = [[UILabel alloc] init];
         [_pageNumberLabel setText:@"Page Text"];
         _pageNumberLabel.font = [UIFont boldSystemFontOfSize:14];
@@ -113,7 +113,7 @@
             make.width.mas_equalTo(93);
         }];
         
-        //font size
+        // Font size
         _fontSizeLabel = [[UILabel alloc] init];
         [_fontSizeLabel setText:@"Font Szie"];
         _fontSizeLabel.font = [UIFont boldSystemFontOfSize:14];
@@ -137,7 +137,7 @@
             make.width.mas_equalTo(93);
         }];
         
-        //font index
+        // Font index
         _pageIndexLabel = [[UILabel alloc] init];
         [_pageIndexLabel setText:@"Page Start"];
         _pageIndexLabel.font = [UIFont boldSystemFontOfSize:14];
@@ -163,6 +163,8 @@
     return  self;
 }
 
+#pragma mark - UITextFieldDelegate
+
 - (BOOL)textFieldShouldReturn:(UITextField *)textField {
     [_pageNumberText resignFirstResponder];
     return YES;

+ 0 - 29
PDFViewer/Controller/CPDFHeaderFooterSettingController.h

@@ -1,29 +0,0 @@
-//
-//  HeaderFooterSettingViewController.h
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/21.
-//
-
-#import <UIKit/UIKit.h>
-#import <ComPDFKit/ComPDFKit.h>
-#import "CPDFHeaderFooterAddController.h"
-#import "CPDFHeaderFooterDeleteController.h"
-#import "CPDFHeaderFooterModel.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface CPDFHeaderFooterSettingController : UIViewController
-
-@property (nonatomic,strong) UIImage *image;
-@property (nonatomic,assign) CGSize size;
-@property (nonatomic,strong) CPDFDocument *document;
-@property (nonatomic,strong) CPDFView *pdfView;
-@property (nonatomic,strong) CPDFHeaderFooterAddController *headerFooterControl;
-@property (nonatomic,strong) CPDFHeaderFooterModel *modelData;
-
-- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size WithDocument:(CPDFDocument *)docment WithView:(CPDFView *) pdfView;
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 56
PDFViewer/Controller/CPDFHeaderFooterSettingController.m

@@ -1,56 +0,0 @@
-//
-//  HeaderFooterSettingViewController.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/21.
-//
-
-#import "CPDFHeaderFooterSettingController.h"
-
-@interface CPDFHeaderFooterSettingController ()
-
-@end
-
-@implementation CPDFHeaderFooterSettingController
-
-- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size WithDocument:(CPDFDocument *)docment  WithView:(CPDFView *)pdfView {
-    self = [super init];
-    if (self) {
-        _image = image;
-        _size  = size;
-        _document = docment;
-        _pdfView = pdfView;
-    }
-    return self;
-}
-
-- (void)viewDidLoad {
-    [super viewDidLoad];
-    // Do any additional setup after loading the view.
-    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
-    //add headerfooter action
-    UIAlertAction *addHeaderfooterAction = [UIAlertAction actionWithTitle:@"Add Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-        self.headerFooterControl = [[CPDFHeaderFooterAddController alloc] initWithIamge:self.image WithSize:self.size WithDocument:self.document WithView:self.pdfView];
-        [self addChildViewController:self.headerFooterControl];
-        [self.view addSubview:self.headerFooterControl.view];
-        [self.navigationController pushViewController:self.headerFooterControl animated:NO];
-        self.view.hidden = YES;
-        }];
-    //delete headerfooter action
-    UIAlertAction *deleteHeaderfooterAction = [UIAlertAction actionWithTitle:@"Delete Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-        CPDFHeaderFooterDeleteController *headerFooterDeleteControl = [[CPDFHeaderFooterDeleteController alloc] init];
-        [self addChildViewController:headerFooterDeleteControl];
-        [self.view addSubview:headerFooterDeleteControl.view];
-        }];
-    //cancel Action
-    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-            NSLog(@"Cancel Action");
-        self.view.hidden = YES;
-        }];
-    [alertController addAction:addHeaderfooterAction];
-    [alertController addAction:deleteHeaderfooterAction];
-    [alertController addAction:cancelAction];
-    [self presentViewController:alertController animated:YES completion:nil];
-}
-
-@end

+ 108 - 56
PDFViewer/Controller/CPDFViewController.m

@@ -10,22 +10,18 @@
 #import "CPDFViewController.h"
 #import "CPDFHeaderFooterAddController.h"
 #import "CPDFHeaderFooterDeleteController.h"
-#import "CPDFBatesSettingController.h"
-#import "CPDFHeaderFooterSettingController.h"
+#import "CPDFBatesDeleteViewController.h"
+#import "CPDFBatesAddViewController.h"
 #import "CPDFBatesModel.h"
 
 @interface CPDFViewController () <UIActionSheetDelegate>
 
 @property (nonatomic,strong) CPDFKitPlatformImage *image;
 @property (nonatomic,assign) CGSize size;
-@property (nonatomic,strong) CPDFHeaderFooter *headerFooter;
-@property (nonatomic,strong) CPDFBates *bates;
 @property (nonatomic,strong) CPDFDocument *document;
 @property (nonatomic,strong) CPDFView *pdfView;
-@property (nonatomic,strong) CPDFHeaderFooterSettingController *headefooterControl;
 @property (nonatomic,strong) CPDFHeaderFooterModel *modelData;
 @property (nonatomic,strong) CPDFBatesModel *modelBatesData;
-@property (nonatomic,strong) CPDFBatesSettingController *batesBatesControl;
 
 @end
 
@@ -41,73 +37,127 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     // Do any additional setup after loading the view.
-    //add UIBarButtonItem in Navigation
+    // Add UIBarButtonItem in Navigation
     self.navigationController.toolbarHidden = YES;
     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
+    
+    // Setting URL
     NSURL *url = [NSURL fileURLWithPath:_path];
     _document = [[CPDFDocument alloc] initWithURL:url];
-    //get document frist image
+    
+    // Get document frist image
     CPDFPage *page = [_document pageAtIndex:0];
     _size = [_document pageSizeAtIndex:0];
     _image = [page thumbnailOfSize:_size];
-    //get document view
+    
+    // Get document view
     _pdfView = [[CPDFView alloc] initWithFrame:self.view.bounds];
     _pdfView.document = _document;
     _pdfView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [self.view addSubview:_pdfView];
+    
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getHeaderFooterModel:) name:@"getAddHeaderFooterModel" object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deleteHeaderFooter:) name:@"deleteHeaderFooter" object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getBatesMdel:) name:@"getAddBatesModel" object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deleteBates:) name:@"deleteBatesModel" object:nil];
 }
 
-#pragma mark - click event of CPDFViewController's ringhtBarItem
+#pragma mark - Actions
 
 - (void)onClickedOkbtn {
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
-    //add watermark action
+    
+    // Add watermark action
     UIAlertAction *addWatermarkAction = [UIAlertAction actionWithTitle:@"Add Watermark" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
             NSLog(@"addWatermarkAction");
         }];
-    //setting headerfooter action
+    
+    // Setting headerfooter action
     UIAlertAction *settingHeaderFooter = [UIAlertAction actionWithTitle:@"Setting Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-        self.headefooterControl = [[CPDFHeaderFooterSettingController alloc] initWithIamge:self.image WithSize:self.size WithDocument:self.document WithView:self.pdfView];
-        [self addChildViewController:self.headefooterControl];
-        [self.view addSubview:self.headefooterControl.view];
-        [self.navigationController pushViewController:self.headefooterControl animated:NO];
+        
+        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
+        
+        // Add headerfooter action
+        UIAlertAction *addHeaderfooterAction = [UIAlertAction actionWithTitle:@"Add Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            CPDFHeaderFooterAddController *headerFooterControl = [[CPDFHeaderFooterAddController alloc] initWithIamge:self.image WithSize:self.size];
+            
+            [self.navigationController pushViewController:headerFooterControl animated:NO];
+            }];
+        
+        // Delete headerfooter action
+        UIAlertAction *deleteHeaderfooterAction = [UIAlertAction actionWithTitle:@"Delete Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            CPDFHeaderFooterDeleteController *headerFooterDeleteControl = [[CPDFHeaderFooterDeleteController alloc] init];
+            
+            [self addChildViewController:headerFooterDeleteControl];
+            [self.view addSubview:headerFooterDeleteControl.view];
+            }];
+        
+        // Cancel Action
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+                NSLog(@"Cancel Action");
+            }];
+        
+        [alertController addAction:addHeaderfooterAction];
+        [alertController addAction:deleteHeaderfooterAction];
+        [alertController addAction:cancelAction];
+        
+        [self presentViewController:alertController animated:YES completion:nil];
        }];
-    //seeting bates action
+    
+    // Seeting bates action
     UIAlertAction *settingBatesAction = [UIAlertAction actionWithTitle:@"Setting Bates" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-        self.batesBatesControl = [[CPDFBatesSettingController alloc] initWithIamge:self.image WithSize:self.size];
-        [self addChildViewController:self.batesBatesControl];
-        [self.view addSubview:self.batesBatesControl.view];
-        [self.navigationController pushViewController:self.batesBatesControl animated:NO];
+        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
+        
+        UIAlertAction *addBatesAction = [UIAlertAction actionWithTitle:@"Add Bates" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            CPDFBatesAddViewController *batesAddControl = [[CPDFBatesAddViewController alloc] initWithIamge:self.image WithSize:self.size];
+            
+            [self.navigationController pushViewController:batesAddControl animated:NO];
+            }];
+        
+        UIAlertAction *delereBatesAction = [UIAlertAction actionWithTitle:@"Delete Bates" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            CPDFBatesDeleteViewController *batesDeleteControl = [[CPDFBatesDeleteViewController alloc] init];
+            
+            [self addChildViewController:batesDeleteControl];
+            [self.view addSubview:batesDeleteControl.view];
+            }];
+        
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+                NSLog(@"Cancel Action");
+            }];
+        
+        [alertController addAction:addBatesAction];
+        [alertController addAction:delereBatesAction];
+        [alertController addAction:cancelAction];
+        
+        [self presentViewController:alertController animated:YES completion:nil];
        }];
-    //cancel action
+    
+    // Cancel action
     UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
             NSLog(@"Cancel Action");
         }];
+    
+    // Add controller
     [alertController addAction:addWatermarkAction];
     [alertController addAction:settingHeaderFooter];
     [alertController addAction:settingBatesAction];
     [alertController addAction:cancelAction];
-    [self presentViewController:alertController animated:YES completion:nil];
-    self.pdfView = self.headefooterControl.pdfView;
-    [self.view addSubview:self.pdfView];
     
+    [self presentViewController:alertController animated:YES completion:nil];
 }
 
-#pragma mark - add headerfooter function
+#pragma mark - Function
 
-//get headerfooter' model to setting page headerfooter's add functional property
+// Get headerfooter' model to setting page headerfooter's add functional property
 - (void)getHeaderFooterModel:(NSNotification *)addSign {
     _modelData = addSign.userInfo[@"model"];
-    _headerFooter = [self.document headerFooter];
+    CPDFHeaderFooter *headerFooter = [self.document headerFooter];
+    
     NSString *pageIndex = [NSString stringWithFormat:@"0-%lu",self.document.pageCount - 1];
     NSString *text = [[NSString alloc] init];
+    
     switch (_modelData.fontSelcet) {
         case 0:
             text = [NSString stringWithFormat:@"<<%@>>",self.modelData.pageStart];
@@ -127,72 +177,74 @@
         default:
             break;
     }
-    self.headerFooter.pageString = pageIndex;
-    [_headerFooter setText:text atIndex:self.modelData.fontPosition];
-    [_headerFooter setFontSize:self.modelData.fontSize atIndex:self.modelData.fontPosition];
-    [_headerFooter setTextColor:self.modelData.fontColor atIndex:self.modelData.fontPosition];
-    [_headerFooter update];
+    
+    headerFooter.pageString = pageIndex;
+    [headerFooter setText:text atIndex:self.modelData.fontPosition];
+    [headerFooter setFontSize:self.modelData.fontSize atIndex:self.modelData.fontPosition];
+    [headerFooter setTextColor:self.modelData.fontColor atIndex:self.modelData.fontPosition];
+    [headerFooter update];
+    
     NSURL *url = [NSURL fileURLWithPath:self.path];
     [self.document writeToURL:url];
     _document = [[CPDFDocument alloc] initWithURL:url];
     _pdfView = [[CPDFView alloc] initWithFrame:self.view.bounds];
     _pdfView.document = _document;
     _pdfView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+    
    [self.view addSubview:_pdfView];
 }
 
-#pragma mark - add bates function
-
-//get bates' model to setting page bates's add functional property
+// Get bates' model to setting page bates's add functional property
 - (void)getBatesMdel:(NSNotification *)addBatesSign {
     _modelBatesData = addBatesSign.userInfo[@"batesModel"];
-    _bates = [self.document bates];
+    CPDFBates *bates = [self.document bates];
+    
     NSString *pageIndex = [NSString stringWithFormat:@"%@-%lu",self.modelBatesData.pageStart,self.document.pageCount - 1];
-    self.bates.pageString = pageIndex;
+    bates.pageString = pageIndex;
     NSString *text = [NSString stringWithFormat:@"<<%@>>",self.modelBatesData.fontText];
-    [_bates setText:text atIndex:self.modelBatesData.fontPosition];
-    [_bates setFontName:self.modelBatesData.fontName atIndex:self.modelBatesData.fontPosition];
-    [_bates setFontSize:15.0 atIndex:self.modelBatesData.fontPosition];
-    [_bates setTextColor:self.modelBatesData.fontColor atIndex:self.modelBatesData.fontPosition];
-    [_bates update];
-    NSString *test = [self.bates textAtIndex:self.modelBatesData.fontPosition];
-    NSLog(@"%@",test);
+    [bates setText:text atIndex:self.modelBatesData.fontPosition];
+    [bates setFontName:self.modelBatesData.fontName atIndex:self.modelBatesData.fontPosition];
+    [bates setFontSize:15.0 atIndex:self.modelBatesData.fontPosition];
+    [bates setTextColor:self.modelBatesData.fontColor atIndex:self.modelBatesData.fontPosition];
+    [bates update];
+    
     NSURL *url = [NSURL fileURLWithPath:self.path];
     [self.document writeToURL:url];
     _document = [[CPDFDocument alloc] initWithURL:url];
     _pdfView = [[CPDFView alloc] initWithFrame:self.view.bounds];
     _pdfView.document = _document;
     _pdfView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+    
    [self.view addSubview:_pdfView];
 }
 
-#pragma mark - delete headerfooter function
-
-//get headerfooter' model to setting page headerfooter's delete functional property
+// Get headerfooter' model to setting page headerfooter's delete functional property
 - (void)deleteHeaderFooter:(NSNotification *)deleteSign {
-    _headerFooter = [self.document headerFooter];
-    [_headerFooter clear];
+    CPDFHeaderFooter *headerFooter = [self.document headerFooter];
+    [headerFooter clear];
+    
     NSURL *url = [NSURL fileURLWithPath:self.path];
     [self.document writeToURL:url];
     _document = [[CPDFDocument alloc] initWithURL:url];
     _pdfView = [[CPDFView alloc] initWithFrame:self.view.bounds];
     _pdfView.document = _document;
     _pdfView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+    
    [self.view addSubview:_pdfView];
 }
 
-#pragma mark - delete bates function
-
-//get bates' model to setting page bates's delete functional property
+// Get bates' model to setting page bates's delete functional property
 - (void)deleteBates:(NSNotification *)deleteBates {
-    _bates = [self.document bates];
-    [_bates clear];
+    CPDFBates *bates = [self.document bates];
+    [bates clear];
+    
     NSURL *url = [NSURL fileURLWithPath:self.path];
     [self.document writeToURL:url];
     _document = [[CPDFDocument alloc] initWithURL:url];
     _pdfView = [[CPDFView alloc] initWithFrame:self.view.bounds];
     _pdfView.document = _document;
     _pdfView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+    
    [self.view addSubview:_pdfView];
 }
 

PDFViewer/Model/CPDFBatesModel.h → PDFViewer/Controller/Model/CPDFBatesModel.h


PDFViewer/Model/CPDFBatesModel.m → PDFViewer/Controller/Model/CPDFBatesModel.m


PDFViewer/Model/CPDFFontNameModel.h → PDFViewer/Controller/Model/CPDFFontNameModel.h


PDFViewer/Model/CPDFFontNameModel.m → PDFViewer/Controller/Model/CPDFFontNameModel.m


PDFViewer/Model/CPDFHeaderFooterModel.h → PDFViewer/Controller/Model/CPDFHeaderFooterModel.h


PDFViewer/Model/CPDFHeaderFooterModel.m → PDFViewer/Controller/Model/CPDFHeaderFooterModel.m


PDFViewer/Model/CPDFModel.h → PDFViewer/Controller/Model/CPDFModel.h


PDFViewer/Model/CPDFModel.m → PDFViewer/Controller/Model/CPDFModel.m


PDFViewer/Model/CPDFPageFomatModel.h → PDFViewer/Controller/Model/CPDFPageFomatModel.h


PDFViewer/Model/CPDFPageFomatModel.m → PDFViewer/Controller/Model/CPDFPageFomatModel.m


+ 6 - 6
PDFViewer/View/CPDFBatesAddView.m

@@ -14,7 +14,7 @@
     self = [super initWithFrame:frame];
     CGFloat offsetx = 3.5;
     if (self) {
-        //Page number location
+        // Page number location
         _localLabel = [[UILabel alloc] init];
         [_localLabel setText:@"Page number position"];
         _localLabel.font = [UIFont boldSystemFontOfSize:12];
@@ -35,7 +35,7 @@
             make.height.mas_equalTo(44);
         }];
         
-        //alignment
+        // Alignment
         _alignmentLabel = [[UILabel alloc] init];
         [_alignmentLabel setText:@"alignment"];
         _alignmentLabel.font = [UIFont boldSystemFontOfSize:12];
@@ -56,7 +56,7 @@
             make.height.mas_equalTo(44);
         }];
         
-        //font color
+        // Font color
         _colorLabel = [[UILabel alloc] init];
         [_colorLabel setText:@"Font Color"];
         _colorLabel.font = [UIFont boldSystemFontOfSize:12];
@@ -91,7 +91,7 @@
             make.height.mas_equalTo(44);
         }];
         
-        //font index
+        // Font index
         _pageIndexLabel = [[UILabel alloc] init];
         [_pageIndexLabel setText:@"Start Page"];
         _pageIndexLabel.font = [UIFont boldSystemFontOfSize:14];
@@ -113,7 +113,7 @@
             make.width.mas_equalTo(93);
         }];
         
-        //font Name
+        // Font Name
         _fontNameLabel = [[UILabel alloc] init];
         [_fontNameLabel setText:@"Font Name"];
         _fontNameLabel.font = [UIFont boldSystemFontOfSize:14];
@@ -137,7 +137,7 @@
             make.width.mas_equalTo(93);
         }];
         
-        //page number
+        // Page number
         _pageNumberLabel = [[UILabel alloc] init];
         [_pageNumberLabel setText:@"Page Text"];
         _pageNumberLabel.font = [UIFont boldSystemFontOfSize:14];

+ 0 - 31
PDFViewer/View/CPDFDropDownView.h

@@ -1,31 +0,0 @@
-//
-//  DropDownView.h
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/21.
-//
-
-#import <UIKit/UIKit.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface CPDFDropDownView : UIView <UITableViewDelegate,UITableViewDataSource>
-
-@property (nonatomic,strong) UITextField *textField;
-@property (nonatomic,strong) NSArray *list;
-@property (nonatomic,strong) UITableView *listView;
-@property (nonatomic,strong) UIColor *lineColor;
-@property (nonatomic,retain) UIColor *listBgcolor;
-@property (nonatomic,assign) UITextBorderStyle borderStyle;
-@property (nonatomic,assign) BOOL showList;
-@property (nonatomic,assign) CGRect oldFrame;
-@property (nonatomic,assign) CGRect newFrame;
-@property (nonatomic,assign) CGFloat lineWidth;
-
--(void)drawView;
--(void)setShowList:(BOOL)b;
-- (id)initWithFrame:(CGRect)frame WithString:(NSArray *)str;
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 99
PDFViewer/View/CPDFDropDownView.m

@@ -1,99 +0,0 @@
-//
-//  DropDownView.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/21.
-//
-
-#import "CPDFDropDownView.h"
-
-@implementation CPDFDropDownView
-
-- (id)initWithFrame:(CGRect)frame WithString:(NSArray *)str{
-    if (self = [super initWithFrame:frame]) {
-        _list = str;
-        _borderStyle = UITextBorderStyleRoundedRect;
-        _showList = NO;
-        _oldFrame = frame;
-        _newFrame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height*3);
-        _lineColor = [UIColor lightGrayColor];
-        _listBgcolor = [UIColor whiteColor];
-        _lineWidth = 1;
-        self.backgroundColor=[UIColor clearColor];
-
-        [self drawView];
-    }
-    return self;
-}
-
-- (void)dropdown {
-    [_textField resignFirstResponder];
-    if (_showList) {
-        return;
-    } else {
-        [self.superview bringSubviewToFront:self];
-        [self setShowList:YES];
-    }
-    
-}
-
-- (void)drawView {
-    //Textfield
-    _textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, _oldFrame.size.width, _oldFrame.size.height)];
-    _textField.backgroundColor = [UIColor clearColor];
-    _textField.opaque = YES;
-    _textField.textColor = [UIColor blackColor];
-    _textField.font = [UIFont fontWithName:@"Arial" size:12.0];
-    _textField.borderStyle = _borderStyle;
-    //_textField.textAlignment = UITextAlignmentLeft;
-    [self addSubview:_textField];
-    [_textField addTarget:self action:@selector(dropdown)forControlEvents:UIControlEventAllTouchEvents];
-    //dropdown list
-    _listView=[[UITableView alloc]initWithFrame:
-     CGRectMake(_lineWidth,_oldFrame.size.height+_lineWidth,
-    _oldFrame.size.width-_lineWidth*2,
-    _oldFrame.size.height*2-_lineWidth*2)];
-    _listView.dataSource = self;
-    _listView.delegate = self;
-    _listView.backgroundColor = _listBgcolor;
-    _listView.separatorColor = _lineColor;
-    _listView.hidden = !_showList;
-    [self addSubview:_listView];
-}
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-    return  _list.count;
-}
-
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"listwid"];
-    if (cell == nil) {
-        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"listwid"];
-    }
-    cell.textLabel.text = [_list objectAtIndex:indexPath.row];
-    cell.textLabel.font = _textField.font;
-    cell.selectionStyle = UITableViewCellSelectionStyleGray;
-    return  cell;
-}
-
-- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
-    return _oldFrame.size.height;
-}
-
-//When selecting a row in the drop-down list, set the value in the text box to hide the drop-down list
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-    _textField.text = (NSString *)[_list objectAtIndex:indexPath.row];
-    [self setShowList:NO];
-}
-
-- (void)setShowList:(BOOL)b {
-    _showList = b;
-    if (_showList) {
-        self.frame = _newFrame;
-    } else {
-        self.frame = _oldFrame;
-    }
-    _listView.hidden = !b;
-}
-
-@end

+ 4 - 9
PDFViewer/View/CPDFHeaderFooterTextTableView.m

@@ -22,7 +22,7 @@
             make.bottom.equalTo(self.mas_bottom).offset(-44);
         }];
         
-        //title
+        // Title
         _titleView = [[UILabel alloc] init];
         _titleView.font = [UIFont systemFontOfSize:12.0f];
         _titleView.textColor = [UIColor blackColor];
@@ -38,7 +38,7 @@
             make.height.mas_equalTo(33);
         }];
         
-        //view button at the bottom
+        // View button at the bottom
         _bottomView = [[UIView alloc] init];
         _bottomView.backgroundColor = [UIColor systemGray5Color];
         [self addSubview:_bottomView];
@@ -49,7 +49,7 @@
             make.height.mas_equalTo(44);
         }];
         
-        //OK
+        // OK
         _okBtn = [[UIButton alloc] init];
         [_okBtn setTitle:@"OK" forState:UIControlStateNormal];
         _okBtn.titleLabel.font = [UIFont systemFontOfSize:12];
@@ -62,12 +62,11 @@
             make.width.mas_equalTo(40);
         }];
         
-        //Cancel
+        // Cancel
         _cancelBtn = [[UIButton alloc] initWithFrame:CGRectZero];
         [_cancelBtn setTitle:@"Cancel" forState:UIControlStateNormal];
         _cancelBtn.titleLabel.font = [UIFont systemFontOfSize:12];
         _cancelBtn.backgroundColor = [UIColor systemGray3Color];
-        //[_cancelBtn addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
         [self.bottomView addSubview:_cancelBtn];
         [self.okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
             make.top.equalTo(self.bottomView.mas_top).offset(6);
@@ -79,8 +78,4 @@
     return self;
 }
 
-- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
-    
-}
-
 @end