| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- //
- // ImageScrollerViewController.m
- // RedAnt ERP Mobile
- //
- // Created by Ray on 12/18/15.
- // Copyright © 2015 United Software Applications, Inc. All rights reserved.
- //
- #import "ImageScrollerViewController.h"
- #import "AppDelegate.h"
- @interface ImageScrollerViewController ()
- @end
- @implementation ImageScrollerViewController
- -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
- {
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- [appDelegate didRotated];
- UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
- if (UIInterfaceOrientationIsLandscape(orientation)|| UIInterfaceOrientationIsPortrait(orientation))
- {
-
- int index = self.imgShowView.curIndex;
- for(UIView* v in self.view.subviews)
- {
- if(v.tag==199)
- [ v removeFromSuperview];
- }
-
- self.imgShowView = [[ImageScrollerView alloc]
- 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
- withSourceData:_data
- withIndex:index];
- self.imgShowView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
-
- self.imgShowView.tag = 199;
- [self.view addSubview:self.imgShowView];
-
- }
-
-
-
-
- }
- - (id)initWithSourceData:(NSMutableArray *)data withIndex:(NSInteger)index{
-
- self = [super init];
-
- if (self) {
- self.use_url =false;
- self=[self init];
-
- _data = data;
- _index = index;
- }
-
- return self;
-
- }
- - (id)initWithSourceURL:(NSMutableArray *)urls withIndex:(NSInteger)index{
-
-
- self = [super init];
- if (self) {
-
- self=[self init];
- // NSMutableArray* data = [[NSMutableArray alloc]init];
- // UIImage* qrimg=[QRCodeGenerator qrImageForString:[section_json valueForKey:@"model_name"] imageSize:350];
- // if(qrimg!=nil)
- // [cell AddPhoto:qrimg];
-
-
- self.use_url =true;
-
- _data = urls;
- _index = index;
- }
-
-
- return self;
-
- }
- - (BOOL)prefersStatusBarHidden
- {
- return YES; //返回NO表示要显示,返回YES将hiden
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
-
- self.automaticallyAdjustsScrollViewInsets = NO;
-
- self.view.backgroundColor = [UIColor blackColor];
- // self.prefersStatusBarHidden = TRUE;
-
- self.btn_close = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width-37, 5, 32, 32)];
- [self.btn_close setBackgroundImage:[UIImage imageNamed:@"iv_close"] forState:UIControlStateNormal];
- [self.btn_close addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
-
-
- // UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
- // [self.view addGestureRecognizer:tap];
-
- self.btn_close.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- [self.view addSubview:self.btn_close];
- [self creatImgShow];
- // Do any additional setup after loading the view.
- }
- - (void)backAction{
- [self.navigationController popViewControllerAnimated:true];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)creatImgShow{
- ImageScrollerView *imgShowView=nil;
- if(self.use_url)
- {
- imgShowView= [[ImageScrollerView alloc]
- 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
- withSourceURL:_data
- withIndex:_index];
- }
- else
- {
- imgShowView= [[ImageScrollerView alloc]
- 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
- withSourceData:_data
- withIndex:_index];
- }
- // 解决谦让
- // [imgShowView requireDoubleGestureRecognizer:[[self.view gestureRecognizers] lastObject]];
-
- // UIViewAutoresizingNone = 0,
- // UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
- // UIViewAutoresizingFlexibleWidth = 1 << 1,
- // UIViewAutoresizingFlexibleRightMargin = 1 << 2,
- // UIViewAutoresizingFlexibleTopMargin = 1 << 3,
- // UIViewAutoresizingFlexibleHeight = 1 << 4,
- // UIViewAutoresizingFlexibleBottomMargin = 1 << 5
-
- imgShowView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
- self.imgShowView = imgShowView;
- self.imgShowView.tag = 199;
- [self.view addSubview:imgShowView];
- }
- //- (void)tapAction:(UITapGestureRecognizer *)tap
- //{
- //[self.navigationController popViewControllerAnimated:true];
- //
- //}
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|