RAPhotoPreviewController.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // RAPhotoPreviewController.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/6/5.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RAPhotoPreviewController.h"
  9. @interface RAPhotoPreviewController () <UIScrollViewDelegate>
  10. @property (strong, nonatomic) IBOutlet UIImageView *photoImageView;
  11. @property (strong, nonatomic) IBOutlet UIScrollView *photoScrollView;
  12. @end
  13. @implementation RAPhotoPreviewController
  14. + (instancetype)viewControllerFromStoryboard {
  15. RAPhotoPreviewController *previewVC = [[UIStoryboard storyboardWithName:@"PhotoPreview" bundle:nil] instantiateViewControllerWithIdentifier:[self storyboardID]];
  16. return previewVC;
  17. }
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. // Do any additional setup after loading the view.
  21. self.photoImageView.image = self.image;
  22. [self configureNavigationBar];
  23. }
  24. - (void)didReceiveMemoryWarning {
  25. [super didReceiveMemoryWarning];
  26. // Dispose of any resources that can be recreated.
  27. }
  28. - (void)configureNavigationBar {
  29. UIBarButtonItem *deleteItem = [[UIBarButtonItem alloc] initWithTitle:@"delete" style:UIBarButtonItemStylePlain target:self action:@selector(deleteActionClick:)];
  30. self.navigationItem.rightBarButtonItem = deleteItem;
  31. }
  32. #pragma mark - Action
  33. - (void)deleteActionClick:(UIBarButtonItem *)sender {
  34. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"Are you sure you want to delete it" preferredStyle:UIAlertControllerStyleAlert];
  35. __weak typeof(self) weakSelf = self;
  36. UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  37. if (weakSelf.completion) {
  38. weakSelf.completion();
  39. }
  40. [weakSelf.navigationController popViewControllerAnimated:YES];
  41. }];
  42. UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  43. }];
  44. [alertVC addAction:noAction];
  45. [alertVC addAction:yesAction];
  46. [self presentViewController:alertVC animated:YES completion:nil];
  47. }
  48. #pragma mark - Scroll Delegate
  49. - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
  50. return self.photoImageView;
  51. }
  52. @end