ImageScrollerViewController.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //
  2. // ImageScrollerViewController.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 12/18/15.
  6. // Copyright © 2015 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "ImageScrollerViewController.h"
  9. #import "AppDelegate.h"
  10. @interface ImageScrollerViewController ()
  11. @end
  12. @implementation ImageScrollerViewController
  13. -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
  14. {
  15. UIApplication * app = [UIApplication sharedApplication];
  16. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  17. [appDelegate didRotated];
  18. UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
  19. if (UIInterfaceOrientationIsLandscape(orientation)|| UIInterfaceOrientationIsPortrait(orientation))
  20. {
  21. int index = self.imgShowView.curIndex;
  22. for(UIView* v in self.view.subviews)
  23. {
  24. if(v.tag==199)
  25. [ v removeFromSuperview];
  26. }
  27. self.imgShowView = [[ImageScrollerView alloc]
  28. initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y+42, self.view.frame.size.width, self.view.frame.size.height-84) //self.view.frame
  29. withSourceData:_data
  30. withIndex:index];
  31. self.imgShowView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
  32. self.imgShowView.tag = 199;
  33. [self.view addSubview:self.imgShowView];
  34. }
  35. }
  36. - (id)initWithSourceData:(NSMutableArray *)data withIndex:(NSInteger)index{
  37. self = [super init];
  38. if (self) {
  39. self=[self init];
  40. _data = data;
  41. _index = index;
  42. }
  43. return self;
  44. }
  45. - (BOOL)prefersStatusBarHidden
  46. {
  47. return YES; //返回NO表示要显示,返回YES将hiden
  48. }
  49. - (void)viewDidLoad {
  50. [super viewDidLoad];
  51. self.automaticallyAdjustsScrollViewInsets = NO;
  52. self.view.backgroundColor = [UIColor blackColor];
  53. // self.prefersStatusBarHidden = TRUE;
  54. self.btn_close = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width-37, 5, 32, 32)];
  55. [self.btn_close setBackgroundImage:[UIImage imageNamed:@"iv_close"] forState:UIControlStateNormal];
  56. [self.btn_close addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  57. // UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
  58. // [self.view addGestureRecognizer:tap];
  59. self.btn_close.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  60. [self.view addSubview:self.btn_close];
  61. [self creatImgShow];
  62. // Do any additional setup after loading the view.
  63. }
  64. - (void)backAction{
  65. [self.navigationController popViewControllerAnimated:true];
  66. }
  67. - (void)didReceiveMemoryWarning {
  68. [super didReceiveMemoryWarning];
  69. // Dispose of any resources that can be recreated.
  70. }
  71. - (void)creatImgShow{
  72. ImageScrollerView *imgShowView = [[ImageScrollerView alloc]
  73. initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y+42, self.view.frame.size.width, self.view.frame.size.height-84) //self.view.frame
  74. withSourceData:_data
  75. withIndex:_index];
  76. // 解决谦让
  77. // [imgShowView requireDoubleGestureRecognizer:[[self.view gestureRecognizers] lastObject]];
  78. // UIViewAutoresizingNone = 0,
  79. // UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
  80. // UIViewAutoresizingFlexibleWidth = 1 << 1,
  81. // UIViewAutoresizingFlexibleRightMargin = 1 << 2,
  82. // UIViewAutoresizingFlexibleTopMargin = 1 << 3,
  83. // UIViewAutoresizingFlexibleHeight = 1 << 4,
  84. // UIViewAutoresizingFlexibleBottomMargin = 1 << 5
  85. imgShowView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
  86. self.imgShowView = imgShowView;
  87. self.imgShowView.tag = 199;
  88. [self.view addSubview:imgShowView];
  89. }
  90. //- (void)tapAction:(UITapGestureRecognizer *)tap
  91. //{
  92. //[self.navigationController popViewControllerAnimated:true];
  93. //
  94. //}
  95. /*
  96. #pragma mark - Navigation
  97. // In a storyboard-based application, you will often want to do a little preparation before navigation
  98. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  99. // Get the new view controller using [segue destinationViewController].
  100. // Pass the selected object to the new view controller.
  101. }
  102. */
  103. @end