Browse Source

PDFView(ios) - 修改后第三版(代理传值)

yangliuhua 2 years ago
parent
commit
82c1ce5101

+ 0 - 24
PDFViewer.xcodeproj/project.pbxproj

@@ -7,17 +7,14 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
-		C94D478C29344878008983FB /* CPDFFontNameModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C94D478B29344878008983FB /* CPDFFontNameModel.m */; };
 		C94D47932934A961008983FB /* ComPDFKit.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C94D47912934808C008983FB /* ComPDFKit.xcframework */; };
 		C94D47942934A961008983FB /* ComPDFKit.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C94D47912934808C008983FB /* ComPDFKit.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 		C96D13932924793800CC92C7 /* btn_more.png in Resources */ = {isa = PBXBuildFile; fileRef = C96D13922924793800CC92C7 /* btn_more.png */; };
 		C96D13962924DD7E00CC92C7 /* CPDFHeaderFooterAddController.m in Sources */ = {isa = PBXBuildFile; fileRef = C96D13952924DD7E00CC92C7 /* CPDFHeaderFooterAddController.m */; };
 		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 */; };
 		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 */; };
 		C993B918292B5BC500D8F474 /* CPDFHeaderFooterModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B917292B5BC500D8F474 /* CPDFHeaderFooterModel.m */; };
@@ -33,7 +30,6 @@
 		C9E65169292CBC31001B2C9D /* MASCompositeConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E6515B292CBC31001B2C9D /* MASCompositeConstraint.m */; };
 		C9E6516A292CBC31001B2C9D /* NSArray+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E6515C292CBC31001B2C9D /* NSArray+MASAdditions.m */; };
 		C9E6517029306274001B2C9D /* CPDFHeaderFooterTextTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E6516F29306274001B2C9D /* CPDFHeaderFooterTextTableView.m */; };
-		C9E6517329308A6C001B2C9D /* CPDFPageFomatModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E6517229308A6C001B2C9D /* CPDFPageFomatModel.m */; };
 		EC62978E29220F8300D339EE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EC62978D29220F8300D339EE /* AppDelegate.m */; };
 		EC62979129220F8300D339EE /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EC62979029220F8300D339EE /* SceneDelegate.m */; };
 		EC62979429220F8300D339EE /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EC62979329220F8300D339EE /* ViewController.m */; };
@@ -61,8 +57,6 @@
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
-		C94D478A29344878008983FB /* CPDFFontNameModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFFontNameModel.h; sourceTree = "<group>"; };
-		C94D478B29344878008983FB /* CPDFFontNameModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFFontNameModel.m; sourceTree = "<group>"; };
 		C94D47912934808C008983FB /* ComPDFKit.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = ComPDFKit.xcframework; sourceTree = "<group>"; };
 		C96D13922924793800CC92C7 /* btn_more.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = btn_more.png; sourceTree = "<group>"; };
 		C96D13942924DD7E00CC92C7 /* CPDFHeaderFooterAddController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFHeaderFooterAddController.h; sourceTree = "<group>"; };
@@ -70,12 +64,8 @@
 		C96D13972924E09300CC92C7 /* CPDFHeaderFooterAddView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CPDFHeaderFooterAddView.h; path = PDFViewer/Controller/CPDFHeaderFooterAddView.h; sourceTree = SOURCE_ROOT; };
 		C96D13982924E09300CC92C7 /* CPDFHeaderFooterAddView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = CPDFHeaderFooterAddView.m; path = PDFViewer/Controller/CPDFHeaderFooterAddView.m; sourceTree = SOURCE_ROOT; };
 		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>"; };
 		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>"; };
-		C993B908292654BE00D8F474 /* CPDFBatesDeleteViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFBatesDeleteViewController.m; sourceTree = "<group>"; };
 		C993B90A29271FCA00D8F474 /* CPDFBatesAddViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFBatesAddViewController.h; sourceTree = "<group>"; };
 		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>"; };
@@ -111,8 +101,6 @@
 		C9E6515F292CBC31001B2C9D /* MASConstraint+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MASConstraint+Private.h"; sourceTree = "<group>"; };
 		C9E6516E29306274001B2C9D /* CPDFHeaderFooterTextTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFHeaderFooterTextTableView.h; sourceTree = "<group>"; };
 		C9E6516F29306274001B2C9D /* CPDFHeaderFooterTextTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFHeaderFooterTextTableView.m; sourceTree = "<group>"; };
-		C9E6517129308A6C001B2C9D /* CPDFPageFomatModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFPageFomatModel.h; sourceTree = "<group>"; };
-		C9E6517229308A6C001B2C9D /* CPDFPageFomatModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFPageFomatModel.m; 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>"; };
 		EC62978D29220F8300D339EE /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
@@ -241,10 +229,6 @@
 				EC6297B7292239A700D339EE /* CPDFModel.m */,
 				C993B916292B5BC500D8F474 /* CPDFHeaderFooterModel.h */,
 				C993B917292B5BC500D8F474 /* CPDFHeaderFooterModel.m */,
-				C94D478A29344878008983FB /* CPDFFontNameModel.h */,
-				C94D478B29344878008983FB /* CPDFFontNameModel.m */,
-				C9E6517129308A6C001B2C9D /* CPDFPageFomatModel.h */,
-				C9E6517229308A6C001B2C9D /* CPDFPageFomatModel.m */,
 			);
 			path = Model;
 			sourceTree = "<group>";
@@ -275,10 +259,6 @@
 				ECC8831C2923352B00F6392E /* CPDFViewController.m */,
 				C96D13942924DD7E00CC92C7 /* CPDFHeaderFooterAddController.h */,
 				C96D13952924DD7E00CC92C7 /* CPDFHeaderFooterAddController.m */,
-				C993B8FC2925E52800D8F474 /* CPDFHeaderFooterDeleteController.h */,
-				C993B8FD2925E52800D8F474 /* CPDFHeaderFooterDeleteController.m */,
-				C993B907292654BE00D8F474 /* CPDFBatesDeleteViewController.h */,
-				C993B908292654BE00D8F474 /* CPDFBatesDeleteViewController.m */,
 				C993B90A29271FCA00D8F474 /* CPDFBatesAddViewController.h */,
 				C993B90B29271FCA00D8F474 /* CPDFBatesAddViewController.m */,
 				EC6297AD29222D3100D339EE /* Model */,
@@ -365,7 +345,6 @@
 				C993B918292B5BC500D8F474 /* CPDFHeaderFooterModel.m in Sources */,
 				C9E65169292CBC31001B2C9D /* MASCompositeConstraint.m in Sources */,
 				C96D13962924DD7E00CC92C7 /* CPDFHeaderFooterAddController.m in Sources */,
-				C993B909292654BE00D8F474 /* CPDFBatesDeleteViewController.m in Sources */,
 				EC62979429220F8300D339EE /* ViewController.m in Sources */,
 				EC6297B8292239A700D339EE /* CPDFModel.m in Sources */,
 				C9E65167292CBC31001B2C9D /* MASConstraint.m in Sources */,
@@ -377,17 +356,14 @@
 				C993B90C29271FCA00D8F474 /* CPDFBatesAddViewController.m in Sources */,
 				C9E65166292CBC31001B2C9D /* ViewController+MASAdditions.m in Sources */,
 				C9E65160292CBC31001B2C9D /* MASViewConstraint.m in Sources */,
-				C94D478C29344878008983FB /* CPDFFontNameModel.m in Sources */,
 				C9E65168292CBC31001B2C9D /* MASLayoutConstraint.m in Sources */,
 				C993B90F2927200400D8F474 /* CPDFBatesAddView.m in Sources */,
 				EC62978E29220F8300D339EE /* AppDelegate.m in Sources */,
 				EC62979F29220F8400D339EE /* main.m in Sources */,
 				C9E6517029306274001B2C9D /* CPDFHeaderFooterTextTableView.m in Sources */,
 				C9E6516A292CBC31001B2C9D /* NSArray+MASAdditions.m in Sources */,
-				C993B8FE2925E52800D8F474 /* CPDFHeaderFooterDeleteController.m in Sources */,
 				EC6297BD292239C200D339EE /* CPDFListController.m in Sources */,
 				EC62979129220F8300D339EE /* SceneDelegate.m in Sources */,
-				C9E6517329308A6C001B2C9D /* CPDFPageFomatModel.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

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


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

@@ -78,8 +78,8 @@
             filePath = "PDFViewer/Controller/CPDFBatesAddViewController.m"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "163"
-            endingLineNumber = "163"
+            startingLineNumber = "161"
+            endingLineNumber = "161"
             landmarkName = "-changeText:"
             landmarkType = "7">
          </BreakpointContent>

+ 0 - 2
PDFViewer/Controller/CPDFBatesAddViewController.h

@@ -8,8 +8,6 @@
 #import <UIKit/UIKit.h>
 #import "CPDFBatesAddView.h"
 #import "CPDFHeaderFooterAddController.h"
-#import "CPDFFontNameModel.h"
-
 
 NS_ASSUME_NONNULL_BEGIN
 

+ 9 - 11
PDFViewer/Controller/CPDFBatesAddViewController.m

@@ -79,9 +79,7 @@
         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];
-            [_dataArray addObject:fontNameModel];
+            [_dataArray addObject:fontNameArray[i]];
         }
     }
     return _dataArray;
@@ -123,27 +121,27 @@
         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"pageFormat"];
     }
     
-    cell.textLabel.text = [self.dataArray[indexPath.row] fontName];
+    cell.textLabel.text = self.dataArray[indexPath.row];
     return cell;
 }
 
 #pragma mark - UITableViewDelegate
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-    self.batesAddView.fontNameText.text = [self.dataArray[indexPath.row] fontName];
+    self.batesAddView.fontNameText.text = self.dataArray[indexPath.row];
     
-    self.modelData.fontName = [self.dataArray[indexPath.row] fontName];
+    self.modelData.fontName = self.dataArray[indexPath.row];
     
-    self.showLabel.font = [UIFont fontWithName:[self.dataArray[indexPath.row] fontName] size:5];
+    self.showLabel.font = [UIFont fontWithName:self.dataArray[indexPath.row] size:5];
 }
 
 #pragma mark - Actions
 
 // Done button enable
 - (void)doneBatesClick:(UIBarButtonItem *)btn {
-    NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:self.modelData,@"batesModel", nil];
-    NSNotification *notification = [NSNotification notificationWithName:@"getAddBatesModel" object:nil userInfo:dict];
-    [[NSNotificationCenter defaultCenter] postNotification:notification];
+    if ([self.delegate respondsToSelector:@selector(changBatesModelData:)]) {
+        [self.delegate changBatesModelData:self.modelData];
+    }
     [self.navigationController popViewControllerAnimated:YES];
 }
 
@@ -156,7 +154,7 @@
     [_fontName removeFromSuperview];
 }
 
-#pragma mark - UI Actions
+#pragma mark - UI Functions
 
 // Get page text for bates's model
 - (void)changeText:(UITextField *)text {

+ 0 - 16
PDFViewer/Controller/CPDFBatesDeleteViewController.h

@@ -1,16 +0,0 @@
-//
-//  BatesDeleteViewController.h
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/17.
-//
-
-#import <UIKit/UIKit.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface CPDFBatesDeleteViewController : UIViewController
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 37
PDFViewer/Controller/CPDFBatesDeleteViewController.m

@@ -1,37 +0,0 @@
-//
-//  BatesDeleteViewController.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/17.
-//
-
-#import "CPDFBatesDeleteViewController.h"
-
-@interface CPDFBatesDeleteViewController ()
-
-@end
-
-@implementation CPDFBatesDeleteViewController
-
-- (void)viewDidLoad {
-    [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];
-}
-
-@end

+ 9 - 1
PDFViewer/Controller/CPDFHeaderFooterAddController.h

@@ -11,7 +11,6 @@
 #import "CPDFHeaderFooterAddView.h"
 #import "CPDFHeaderFooterModel.h"
 #import "CPDFHeaderFooterTextTableView.h"
-#import "CPDFPageFomatModel.h"
 #import "Masonry.h"
 
 NS_ASSUME_NONNULL_BEGIN
@@ -34,6 +33,14 @@ typedef struct PositionRec {
     CGAligment aligment;
 }PositionRec;
 
+@protocol CPDFModelDataDelegate <NSObject>
+
+@optional
+- (void)changeHeaderFooterModelData:(CPDFHeaderFooterModel *)modelData;
+- (void)changBatesModelData:(CPDFHeaderFooterModel *)modelData;
+
+@end
+
 @interface CPDFHeaderFooterAddController : UIViewController  <UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>
 
 - (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size;
@@ -53,6 +60,7 @@ typedef struct PositionRec {
 @property (nonatomic,strong) UILabel *showLabel;
 @property (nonatomic,strong) UIImageView *imageView;
 @property (nonatomic,strong) CPDFHeaderFooterModel *modelData;
+@property (nonatomic,weak) id<CPDFModelDataDelegate> delegate;
 
 @end
 

+ 9 - 10
PDFViewer/Controller/CPDFHeaderFooterAddController.m

@@ -125,9 +125,7 @@
         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];
-            [_dataArray addObject:pageFormatMode];
+            [_dataArray addObject:pageFormatArray[i]];
         }
     }
     return _dataArray;
@@ -178,18 +176,18 @@
         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"pageFormat"];
     }
     
-    cell.textLabel.text = [self.dataArray[indexPath.row] pageFormat];
+    cell.textLabel.text = self.dataArray[indexPath.row];
     return cell;
 }
 
 #pragma mark - UITableViewDelegate
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-    self.headerFooterview.pageNumberText.text = [self.dataArray[indexPath.row] pageFormat];
+    self.headerFooterview.pageNumberText.text = self.dataArray[indexPath.row];
     
     self.modelData.fontSelcet = indexPath.row;
     
-    self.showLabel.text = [self.dataArray[indexPath.row] pageFormat];
+    self.showLabel.text = self.dataArray[indexPath.row];
 }
 
 #pragma mark - Actions
@@ -201,9 +199,10 @@
 
 // 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];
-    [[NSNotificationCenter defaultCenter] postNotification:notification];
+    if ([self.delegate respondsToSelector:@selector(changeHeaderFooterModelData:)]) {
+        [self.delegate changeHeaderFooterModelData:self.modelData];
+    }
+    
     [self.navigationController popViewControllerAnimated:YES];
 }
 
@@ -211,7 +210,7 @@
     [self.pageFormat removeFromSuperview];
 }
 
-#pragma mark - UI Actions
+#pragma mark - UI Functions
 
 // Get page start for headerfooter's Model
 - (void)changePageStart:(UITextField *)text {

+ 4 - 0
PDFViewer/Controller/CPDFHeaderFooterAddView.m

@@ -39,6 +39,8 @@
     return  self;
 }
 
+#pragma mark - Layout
+
 - (void)layoutSubviews {
     [super layoutSubviews];
     CGFloat offsetx = 3.5;
@@ -89,6 +91,8 @@
     }];
 }
 
+#pragma mark - Assignment
+
 - (void)setText {
     // Page number location
     [self.localLabel setText:@"Page number position"];

+ 0 - 16
PDFViewer/Controller/CPDFHeaderFooterDeleteController.h

@@ -1,16 +0,0 @@
-//
-//  HeaderFooterDeleteViewController.h
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/17.
-//
-
-#import <UIKit/UIKit.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface CPDFHeaderFooterDeleteController : UIViewController
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 39
PDFViewer/Controller/CPDFHeaderFooterDeleteController.m

@@ -1,39 +0,0 @@
-//
-//  HeaderFooterDeleteViewController.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/17.
-//
-
-#import "CPDFHeaderFooterDeleteController.h"
-
-@interface CPDFHeaderFooterDeleteController ()
-
-#define PAGENUMBER YES;
-
-@end
-
-@implementation CPDFHeaderFooterDeleteController
-
-- (void)viewDidLoad {
-    [super viewDidLoad];
-    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Delete Page Number" message:@"Are you sure delete all pages number" preferredStyle:UIAlertControllerStyleAlert];
-    
-    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-        NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:@"1",@"delete", nil];
-        NSNotification *notification = [NSNotification notificationWithName:@"deleteHeaderFooter" 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];
-}
-
-@end

+ 66 - 27
PDFViewer/Controller/CPDFViewController.m

@@ -9,11 +9,9 @@
 #import <ComPDFKit/CPDFHeaderFooter.h>
 #import "CPDFViewController.h"
 #import "CPDFHeaderFooterAddController.h"
-#import "CPDFHeaderFooterDeleteController.h"
-#import "CPDFBatesDeleteViewController.h"
 #import "CPDFBatesAddViewController.h"
 
-@interface CPDFViewController () <UIActionSheetDelegate>
+@interface CPDFViewController () <UIActionSheetDelegate,CPDFModelDataDelegate>
 
 @property (nonatomic,strong) CPDFKitPlatformImage *image;
 @property (nonatomic,assign) CGSize size;
@@ -53,15 +51,11 @@
     _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];
+   [self.view addSubview:_pdfView];
 }
 
-#pragma mark - Actions
+#pragma mark - CPDFViewController Actions
 
 - (void)onClickedOkbtn {
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
@@ -95,6 +89,8 @@
     [self presentViewController:alertController animated:YES completion:nil];
 }
 
+#pragma mark - Setting Alert
+
 // Setting headerfooter action
 - (void)settingHeaterFooterAction {
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
@@ -103,15 +99,15 @@
     UIAlertAction *addHeaderfooterAction = [UIAlertAction actionWithTitle:@"Add Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
         CPDFHeaderFooterAddController *headerFooterControl = [[CPDFHeaderFooterAddController alloc] initWithIamge:self.image WithSize:self.size];
         
+        headerFooterControl.delegate = self;
+        
         [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];
+        [self deleteHeaderFooterAction];
         }];
     
     // Cancel Action
@@ -133,14 +129,14 @@
     UIAlertAction *addBatesAction = [UIAlertAction actionWithTitle:@"Add Bates" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
         CPDFBatesAddViewController *batesAddControl = [[CPDFBatesAddViewController alloc] initWithIamge:self.image WithSize:self.size];
         
+        batesAddControl.delegate = self;
+        
         [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];
+        [self deleteBatesAction];
         }];
     
     UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
@@ -154,16 +150,54 @@
     [self presentViewController:alertController animated:YES completion:nil];
 }
 
-#pragma mark - Function
+#pragma mark - Delete Alert
+
+// Detele headerfootr action
+- (void)deleteHeaderFooterAction {
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Delete Page Number" message:@"Are you sure delete all pages number" preferredStyle:UIAlertControllerStyleAlert];
+    
+    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        [self deleteHeaderFooter];
+        }];
+    
+    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];
+}
+
+// Delete bates action
+- (void)deleteBatesAction {
+    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) {
+        
+        [self deleteBates];
+        }];
+    
+    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];
+}
+
+#pragma mark - CPDFModelDataDelegate
 
 // Get headerfooter' model to setting page headerfooter's add functional property
-- (void)getHeaderFooterModel:(NSNotification *)addSign {
-    CPDFHeaderFooterModel *modelData = addSign.userInfo[@"model"];
+- (void)changeHeaderFooterModelData:(CPDFHeaderFooterModel *)modelData {
     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:@"<<%@>>",modelData.pageStart];
@@ -183,26 +217,28 @@
         default:
             break;
     }
-    
+
     headerFooter.pageString = pageIndex;
     [headerFooter setText:text atIndex:modelData.fontPosition];
     [headerFooter setFontSize:modelData.fontSize atIndex:modelData.fontPosition];
     [headerFooter setTextColor:modelData.fontColor atIndex: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];
 }
 
 // Get bates' model to setting page bates's add functional property
-- (void)getBatesMdel:(NSNotification *)addBatesSign {
-    CPDFHeaderFooterModel *modelBatesData = addBatesSign.userInfo[@"batesModel"];
+- (void)changBatesModelData:(CPDFHeaderFooterModel *)modelData {
+    CPDFHeaderFooterModel *modelBatesData = modelData;
+    
     CPDFBates *bates = [self.document bates];
     
     NSString *pageIndex = [NSString stringWithFormat:@"%@-%lu",modelBatesData.pageStart,self.document.pageCount - 1];
@@ -216,6 +252,7 @@
     
     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;
@@ -224,8 +261,10 @@
    [self.view addSubview:_pdfView];
 }
 
+#pragma mark - Delete Methods
+
 // Get headerfooter' model to setting page headerfooter's delete functional property
-- (void)deleteHeaderFooter:(NSNotification *)deleteSign {
+- (void)deleteHeaderFooter {
     CPDFHeaderFooter *headerFooter = [self.document headerFooter];
     [headerFooter clear];
     
@@ -240,7 +279,7 @@
 }
 
 // Get bates' model to setting page bates's delete functional property
-- (void)deleteBates:(NSNotification *)deleteBates {
+- (void)deleteBates {
     CPDFBates *bates = [self.document bates];
     [bates clear];
     

+ 0 - 18
PDFViewer/Controller/Model/CPDFFontNameModel.h

@@ -1,18 +0,0 @@
-//
-//  CPDFFontNameModel.h
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/28.
-//
-
-#import <Foundation/Foundation.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface CPDFFontNameModel : NSObject
-
-@property (nonatomic,strong) NSString *fontName;
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 12
PDFViewer/Controller/Model/CPDFFontNameModel.m

@@ -1,12 +0,0 @@
-//
-//  CPDFFontNameModel.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/28.
-//
-
-#import "CPDFFontNameModel.h"
-
-@implementation CPDFFontNameModel
-
-@end

+ 0 - 18
PDFViewer/Controller/Model/CPDFPageFomatModel.h

@@ -1,18 +0,0 @@
-//
-//  CPDFPageFomatModel.h
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/25.
-//
-
-#import <Foundation/Foundation.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface CPDFPageFomatModel : NSObject
-
-@property (nonatomic,strong) NSString *pageFormat;
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 12
PDFViewer/Controller/Model/CPDFPageFomatModel.m

@@ -1,12 +0,0 @@
-//
-//  CPDFPageFomatModel.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/25.
-//
-
-#import "CPDFPageFomatModel.h"
-
-@implementation CPDFPageFomatModel
-
-@end

+ 2 - 0
PDFViewer/View/CPDFAddView.m

@@ -40,6 +40,8 @@
     return self;
 }
 
+#pragma mark - Layout
+
 - (void)layoutSubviews {
     [super layoutSubviews];
     CGFloat offsetx = 3.5;

+ 4 - 0
PDFViewer/View/CPDFBatesAddView.m

@@ -39,6 +39,8 @@
     return  self;
 }
 
+#pragma mark - Layout
+
 - (void)layoutSubviews {
     [super layoutSubviews];
     CGFloat offsetx = 3.5;
@@ -86,6 +88,8 @@
     }];
 }
 
+#pragma mark - Assignment
+
 - (void)setText {
     // Page number location
     [self.localLabel setText:@"Page number position"];

+ 2 - 0
PDFViewer/View/CPDFHeaderFooterTextTableView.m

@@ -42,6 +42,8 @@
     return self;
 }
 
+#pragma mark - Layout
+
 - (void)layoutSubviews {
     [super layoutSubviews];