zoukankan      html  css  js  c++  java
  • iOS 滑动TableView控制导航栏隐藏与显示

    @interface BPArticleViewController ()<UITableViewDelegate,UITableViewDataSource>{

        CGFloat beginContentY;          //开始滑动的位置

        CGFloat endContentY;            //结束滑动的位置

        CGFloat sectionHeaderHeight;

    }

    - (void)viewDidLoad {

        [super viewDidLoad];

         sectionHeaderHeight = 40;

    }

    #pragma mark 下拉导航栏隐藏

    // 当开始滚动视图时,执行该方法。一次有效滑动(开始滑动,滑动一小段距离,只要手指不松开,只算一次滑动),只执行一次。

    - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

    {

        //获取开始位置

        beginContentY = scrollView.contentOffset.y;

    }

    // 滑动scrollView,并且手指离开时执行。一次有效滑动,只执行一次。

    // 当pagingEnabled属性为YES时,不调用,该方法

    - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset

    {

        //获取结束位置

        endContentY = scrollView.contentOffset.y;

        if(endContentY-beginContentY > 100)

        {

            [UIView animateWithDuration:0.25 animations:^{

                CGRect rect = navBarView.frame;

                rect.origin.y = -64;

                navBarView.frame = rect;

                _myTableView.y = navBarView.BottomY;

                 _myTableView.height = SCREENHEIGHT-50;

            }];

            sectionHeaderHeight = 0;

            [_myTableView reloadData];

        } else if(endContentY-beginContentY < -100)  {

            [UIView animateWithDuration:0.25 animations:^{

                CGRect rect = navBarView.frame;

                rect.origin.y = 0;

               navBarView.frame = rect;

             _myTableView.y = navBarView.BottomY;

                _myTableView.height = SCREENHEIGHT-navBarView.height-50;

            } completion:^(BOOL finished) {

                sectionHeaderHeight = 40;

                [_myTableView reloadData];

            }];

        }

    }

    @end

  • 相关阅读:
    不要轻易相信ALV
    什么是SAP Note?如何打SAP Note?
    BW作为源系统连接时,激活DSO或其他模型时提示8*数据源不存在,无法激活
    MDX Parser问题导致BO无法连通BW的解决方案
    BW中跳转报表参数传递
    SD、MM转换BI CONTENT激活错
    如何加载经过许可的第三方断字符
    把SQL Server 错误日志导出为EXCEL 并发送到指定的ftp 或者 共享盘
    tsql 调用作业
    SQL Server 2005 维护计划无法保存
  • 原文地址:https://www.cnblogs.com/liaolijun/p/6774580.html
Copyright © 2011-2022 走看看