zoukankan      html  css  js  c++  java
  • ScrollView定时器复用

    起始偏移量设置为一个宽度

            [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(refreshPic) userInfo:nil repeats:YES];

      

    //定时器实现

    - (void)refreshPic{

        if (_mainScrollView.contentOffset.x/_mainScrollView.frame.size.width==4) {

            _mainScrollView.contentOffset = CGPointMake(0, 0);

        }

            [_mainScrollView setContentOffset:CGPointMake(_mainScrollView.frame.size.width+_mainScrollView.contentOffset.x, 0) animated:YES];

        self.pageCor.currentPage = _mainScrollView.contentOffset.x/_mainScrollView.frame.size.width;

    }

    //手动拖拽实现

    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{

        if (_mainScrollView.contentOffset.x/_mainScrollView.frame.size.width == 5) {

            

            _mainScrollView.contentOffset = CGPointMake(_mainScrollView.frame.size.width, 0);

            self.pageCor.currentPage = 0;

        }else if (_mainScrollView.contentOffset.x/_mainScrollView.frame.size.width==0){

            _mainScrollView.contentOffset = CGPointMake(_mainScrollView.frame.size.width*4, 0);

            self.pageCor.currentPage = 3;

        }else{

            self.pageCor.currentPage = _mainScrollView.contentOffset.x/_mainScrollView.frame.size.width-1;

        }

    //定时器触碰停止,3秒后自动启动

    - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{

        

        _timer.fireDate = [NSDate dateWithTimeIntervalSinceNow:3];

    }

    }

  • 相关阅读:
    安卓日志输出-logger
    RecyclerView的使用(3)之加入Header和Footer
    这些年我踩过的坑——Android
    精简点名IAP错误
    Android中BitmapFactory.Options详解
    在Android下通过ExifInterface类操作图片的Exif信息
    android 生成随机数
    JSON入门之二:org.json的基本使用方法
    Android中的各种访问权限Permission含义
    jar命令的用法详解
  • 原文地址:https://www.cnblogs.com/block123/p/4912383.html
Copyright © 2011-2022 走看看