// // 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"); }]; [alertController addAction:addHeaderfooterAction]; [alertController addAction:deleteHeaderfooterAction]; [alertController addAction:cancelAction]; [self presentViewController:alertController animated:YES completion:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getModel:) name:@"changeModel" object:nil]; } - (void)getModel:(NSNotification *)text { self.modelData = self.headerFooterControl.modelData; NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:self.modelData,@"model", nil]; NSNotification *notification = [NSNotification notificationWithName:@"getSettingModel" object:nil userInfo:dict]; [[NSNotificationCenter defaultCenter] postNotification:notification]; } @end