热更新demo

operationNavigationController.m 9.3KB

    // // operationNavigationController.m // ThePaperHD // // Created by scar1900 on 15/4/1. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "operationNavigationController.h" #import "ATPagingView.h" #import "StyledPageControl.h" @interface operationNavigationController ()<ATPagingViewDelegate,UIGestureRecognizerDelegate> { BOOL hiddenStatusBar; } @property(nonatomic,strong)ATPagingView *pagingView; @property(nonatomic, strong)UIButton *gotoFront; @property(nonatomic, strong)NSMutableArray *imageList; @property(nonatomic, strong)NSMutableArray *imagePoraitList; @property(nonatomic, strong)NSMutableArray *imageViewList; @property(nonatomic, strong)UISwipeGestureRecognizer *leftSwipeGesture; @property(nonatomic, strong)StyledPageControl *pageControl; //页码指示器 @end @implementation operationNavigationController @synthesize delegate; - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; hiddenStatusBar = YES; [self addPageView]; self.leftSwipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(leftSwipeGestureHandler:)]; [self.leftSwipeGesture delaysTouchesBegan]; self.leftSwipeGesture.numberOfTouchesRequired = 1; self.leftSwipeGesture.direction = UISwipeGestureRecognizerDirectionLeft; self.leftSwipeGesture.delegate = self; self.leftSwipeGesture.enabled = NO; [self.pagingView addGestureRecognizer:self.leftSwipeGesture]; [TPUserDefault instance].visitTime = @"0"; [TPUserDefault instance].isAttention = @"0"; [self.view addSubview:self.pageControl]; self.pageControl.currentPage = self.pagingView.currentPageIndex; [self.view addSubview:self.gotoFront]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; if (IS_IPHONE4) { [self.pageControl remakeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.view.centerX); make.bottom.equalTo(self.view.bottom).offset(-70); make.height.equalTo(@10); make.width.equalTo(@140); }]; [self.gotoFront makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view.left); make.right.equalTo(self.view.right); make.height.equalTo(@60); make.top.equalTo(self.view.bottom).offset(-60); }]; }else if (IS_IPHONE5){ [self.pageControl remakeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.view.centerX); make.bottom.equalTo(self.view.bottom).offset(-100); make.height.equalTo(@10); make.width.equalTo(@140); }]; [self.gotoFront makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view.left); make.right.equalTo(self.view.right); make.height.equalTo(@90); make.top.equalTo(self.view.bottom).offset(-90); }]; }else if (rect_screen.size.height == 667){ [self.pageControl remakeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.view.centerX); make.bottom.equalTo(self.view.bottom).offset(-120); make.height.equalTo(@10); make.width.equalTo(@140); }]; [self.gotoFront makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view.left); make.right.equalTo(self.view.right); make.height.equalTo(@110); make.top.equalTo(self.view.bottom).offset(-110); }]; }else if (rect_screen.size.height == 736){ [self.pageControl remakeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.view.centerX); make.bottom.equalTo(self.view.bottom).offset(-130); make.height.equalTo(@10); make.width.equalTo(@140); }]; [self.gotoFront makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view.left); make.right.equalTo(self.view.right); make.height.equalTo(@120); make.top.equalTo(self.view.bottom).offset(-120); }]; } [self.pagingView didRotate]; } - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; } - (ATPagingView*)pagingView { if (!_pagingView) { _pagingView = [[ATPagingView alloc]initWithFrame:self.view.bounds]; _pagingView.gapBetweenPages = 0; _pagingView.recyclingEnabled = NO; _pagingView.backgroundColor = [UIColor whiteColor]; _pagingView.delegate = self; _pagingView.scrollView.bounces = NO; _pagingView.scrollView.scrollEnabled = YES; _pagingView.autoresizingMask = AutoresizingFull; } return _pagingView; } - (StyledPageControl *)pageControl { if (!_pageControl) { _pageControl = [[StyledPageControl alloc] initWithFrame:CGRectZero]; _pageControl.pageControlStyle = PageControlStyleThumb; _pageControl.userInteractionEnabled = NO; _pageControl.hidesForSinglePage = YES; _pageControl.thumbImage = Image(@"welcome/welcome_gray.png"); _pageControl.selectedThumbImage = Image(@"welcome/welcome_white.png"); _pageControl.strokeWidth = 5; _pageControl.gapWidth = 10; _pageControl.diameter = 13; _pageControl.backgroundColor = [UIColor clearColor]; } return _pageControl; } -(UIButton *)gotoFront{ if (!_gotoFront) { _gotoFront = [UIButton buttonWithType:UIButtonTypeCustom]; _gotoFront.backgroundColor = [UIColor clearColor]; [_gotoFront addTarget:self action:@selector(frontSelector:) forControlEvents:UIControlEventTouchUpInside]; } return _gotoFront; } - (BOOL)prefersStatusBarHidden { return hiddenStatusBar; } - (void)addPageView { if (IS_IPHONE4) { self.imageList = [NSMutableArray arrayWithObjects:Image(@"welcome/iphone4S_welcome1.png"), Image(@"welcome/iphone4S_welcome2.png"),nil];//直播页,日期栏口显示有两个症状(bug:3910) }else if (IS_IPHONE5){ self.imageList = [NSMutableArray arrayWithObjects:Image(@"welcome/iphone5_welcome1.png"), Image(@"welcome/iphone5_welcome2.png"),nil]; }else if (rect_screen.size.height == 667){ self.imageList = [NSMutableArray arrayWithObjects:Image(@"welcome/iphone6_welcome1.png"), Image(@"welcome/iphone6_welcome2.png"),nil]; }else if (rect_screen.size.height == 736){ self.imageList = [NSMutableArray arrayWithObjects:Image(@"welcome/iphone6P_welcome1.png"), Image(@"welcome/iphone6P_welcome2.png"),nil]; } [self.imageList enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { if (nil == self.imageViewList) { self.imageViewList = [NSMutableArray array]; } [self.imageViewList addObject:[NSNull null]]; }]; [self.view addSubview:self.pagingView]; self.pageControl.numberOfPages = self.imageList.count; [self.pagingView reloadData]; } #pragma mark - pageView delegate - (NSInteger)numberOfPagesInPagingView:(ATPagingView *)pagingView { return self.imageViewList.count; } - (UIView *)viewForPageInPagingView:(ATPagingView *)pagingView atIndex:(NSInteger)index { id data = self.imageViewList[index]; if (data == [NSNull null]) { UIImageView *imageView = [[UIImageView alloc]init]; imageView.userInteractionEnabled = NO; imageView.frame = self.pagingView.bounds; self.imageViewList[index] = imageView; imageView.autoresizingMask = AutoresizingFull; data = imageView; } UIImageView *view = data; view.image = self.imageList[index]; return self.imageViewList[index]; } - (void)currentPageDidChangeInPagingView:(ATPagingView *)pageView { if (pageView.currentPageIndex != self.imageViewList.count -1) { self.leftSwipeGesture.enabled = NO; }else self.leftSwipeGesture.enabled = YES; UIImageView *imageView = self.imageViewList[self.pagingView.currentPageIndex]; imageView.image = self.imageList[self.pagingView.currentPageIndex]; self.pageControl.currentPage = self.pagingView.currentPageIndex; } - (void)pagesDidChangeInPagingView:(ATPagingView *)pageView { } - (void)pagingViewWillBeginMoving:(ATPagingView *)pageView { } - (void)pagingViewdDidScroll:(UIScrollView *)scrollerView { } - (void)leftSwipeGestureHandler:(id)sender { if ([self.delegate respondsToSelector:@selector(goOutOperateNavigateion)]) { [self.delegate goOutOperateNavigateion]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void) frontSelector:(UIButton *)btn{ if ([self.delegate respondsToSelector:@selector(goOutOperateNavigateion)]) { [self.delegate goOutOperateNavigateion]; } } /* #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