CPDFHeaderFooterSettingController.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // HeaderFooterSettingViewController.m
  3. // PDFViewer
  4. //
  5. // Created by kdanmobile_2 on 2022/11/21.
  6. //
  7. #import "CPDFHeaderFooterSettingController.h"
  8. @interface CPDFHeaderFooterSettingController ()
  9. @end
  10. @implementation CPDFHeaderFooterSettingController
  11. - (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size WithDocument:(CPDFDocument *)docment WithView:(CPDFView *) pdfView {
  12. self = [super init];
  13. if (self) {
  14. _image = image;
  15. _size = size;
  16. _document = docment;
  17. _pdfView = pdfView;
  18. }
  19. return self;
  20. }
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. // Do any additional setup after loading the view.
  24. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  25. //add headerfooter action
  26. UIAlertAction *addHeaderfooterAction = [UIAlertAction actionWithTitle:@"Add Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  27. self.headerFooterControl = [[CPDFHeaderFooterAddController alloc] initWithIamge:self.image WithSize:self.size WithDocument:self.document WithView:self.pdfView];
  28. [self addChildViewController:self.headerFooterControl];
  29. [self.view addSubview:self.headerFooterControl.view];
  30. [self.navigationController pushViewController:self.headerFooterControl animated:NO];
  31. self.view.hidden = YES;
  32. }];
  33. //delete headerfooter action
  34. UIAlertAction *deleteHeaderfooterAction = [UIAlertAction actionWithTitle:@"Delete Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  35. CPDFHeaderFooterDeleteController *headerFooterDeleteControl = [[CPDFHeaderFooterDeleteController alloc] init];
  36. [self addChildViewController:headerFooterDeleteControl];
  37. [self.view addSubview:headerFooterDeleteControl.view];
  38. }];
  39. //cancel Action
  40. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  41. NSLog(@"Cancel Action");
  42. }];
  43. [alertController addAction:addHeaderfooterAction];
  44. [alertController addAction:deleteHeaderfooterAction];
  45. [alertController addAction:cancelAction];
  46. [self presentViewController:alertController animated:YES completion:nil];
  47. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getModel:) name:@"changeModel" object:nil];
  48. }
  49. - (void)getModel:(NSNotification *)text {
  50. self.modelData = self.headerFooterControl.modelData;
  51. NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:self.modelData,@"model", nil];
  52. NSNotification *notification = [NSNotification notificationWithName:@"getSettingModel" object:nil userInfo:dict];
  53. [[NSNotificationCenter defaultCenter] postNotification:notification];
  54. }
  55. @end