代码如下,今天有点忙,不想细说了,看不明白可以联系我

//
// LQXViewController.m
// LQXCallBackBar
//
// Created by 刘祺旭 on 15/4/27.
// Copyright (c) 2015年 CSDN探花花花. All rights reserved.
// #import "LQXViewController.h"
#define LQXWidth self.view.bounds.size.width
#define LQXHeight self.view.bounds.size.height
#define LQXData [NSString stringWithFormat:@"随机数据---%d", arc4random_uniform(1000000)] @interface LQXViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong)UITableView *tableView;
@property (nonatomic, strong)NSMutableArray *dataArray;
@property (nonatomic, assign) BOOL hidden;
@property (nonatomic, assign) BOOL scrollUporDown;
@end @implementation LQXViewController - (void)viewDidLoad {
[super viewDidLoad];
self.tabBarController.tabBar.frame = CGRectMake(0, LQXHeight - 40, LQXWidth, 40);
UIView *statusBarView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, LQXWidth, 20)]; statusBarView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"首页--标题栏.png"]]; [self.view addSubview:statusBarView]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO]; self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 20, LQXWidth, LQXHeight - 20) style:0];
self.tableView.bounces = YES
;
self.tableView.dataSource = self;
self.tableView.delegate = self;
self.tableView.rowHeight = 135;
self.tableView.userInteractionEnabled = YES;
self.tableView.showsHorizontalScrollIndicator = NO;
self.tableView.showsVerticalScrollIndicator = NO;
self.dataArray = [NSMutableArray array];
for (int i = 0; i< 100; i++) {
[self.dataArray addObject:LQXData];
}
[self.view addSubview:self.tableView];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 1;
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
// Return the number of rows in the section.
return self.dataArray.count;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *str = @"reuse";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:0 reuseIdentifier:str];
}
cell.textLabel.text = self.dataArray[indexPath.row];
return cell; } - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
if ([scrollView isEqual:self.tableView]) {
static float newy = 0;
static float oldy = 0;
newy = scrollView.contentOffset.y ;
if (newy != oldy ) {
if (newy > oldy) {
self.scrollUporDown = YES;
}else if(newy < oldy){
self.scrollUporDown = NO;
}
oldy = newy;
}
if (_scrollUporDown == YES) {
self.hidden = YES;
[UIView animateWithDuration:0.5 animations:^{
self.navigationController.navigationBar.frame = CGRectMake(0, -40, LQXWidth, 40);
self.tabBarController.tabBar.frame = CGRectMake(0 , LQXHeight + 40, LQXWidth, 40);
}]; }
else if (_scrollUporDown == NO) {
if (self.hidden == YES) {
[UIView animateWithDuration:0.5 animations:^{
self.navigationController.navigationBar.frame = CGRectMake(0, 20, LQXWidth, 40);
self.tabBarController.tabBar.frame = CGRectMake(0 , LQXHeight , LQXWidth, 40);
}]; self.hidden = NO;
}
} }
} /*
#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

tableView等滚动视图滚动时收缩上下导航栏与标签栏的更多相关文章

  1. [Xcode 实际操作]三、视图控制器-(4)使用UINavigationController导航栏和工具栏

    目录:[Swift]Xcode实际操作 本文将演示如何显示和隐藏导航视图的导航栏和工具栏 打开第一个视图控制器 import UIKit class FirstSubViewController: U ...

  2. React实现顶部固定滑动式导航栏(导航条下拉一定像素时显示原导航栏样式)

    摘要 基于react的框架开发一个顶部固定滑动式的酷炫导航栏,当导航栏置顶时,导航栏沉浸在背景图片里:当鼠标滑动滚轮时,导航栏固定滑动并展示下拉样式. JS部分 相关技术栈:react.antd.re ...

  3. UIScrollView滚动时隐藏底部导航栏问题

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView { NSLog(@"開始滚动"); int currentPostio ...

  4. UIScrollView 滚动视图—IOS开发

    转自:http://blog.csdn.net/iukey/article/details/7319314 UIScrollView 类负责所有基于 UIKit 的滚动操作. 一.创建 CGRect  ...

  5. iOS-UIScrollView滚动视图(转)

    http://blog.csdn.net/iukey/article/details/7319314 UIScrollView 类负责所有基于 UIKit 的滚动操作. 一.创建 CGRect bou ...

  6. Android 自学之滚动视图ScrollView

    滚动视图ScrollView由FarmeLayout派生而出,他就是一个用于为普通组件添加垂直滚动条的组件:ScrollView里面最多包含一个组件,而ScrollView的作用就是为该组件添加一个垂 ...

  7. iOS:视图切换的第二种方式:UINavigationController导航栏控制器

    UINavigationController:一个以栈的形式管理多视图的容器,负责子控制器之间的跳转.由于以栈的方式管理视图,各个视图的切换就是压栈和出栈操作,所以出栈后的视图会立即销毁. 介绍: & ...

  8. [Xcode 实际操作]三、视图控制器-(7)UINavigationController自定义导航按钮

    目录:[Swift]Xcode实际操作 本文将演示设置导航按钮的样式,以及设置导航标题区域的样式. import UIKit class FirstSubViewController: UIViewC ...

  9. phpcmsv9如何实现添加栏目时不在首页内容区显示只在导航栏显示

    之前王晟璟一直使用PHPCMSV9系统建过自己的个人门户网站,同时也建立了一个其他类型的网站,感觉非常不错,我不得不说PHPCMSV9的功能非常齐全,非常强大. 但有一点时常让王晟璟感到很烦脑,那就是 ...

随机推荐

  1. java应用测试报告生成(二):利用ant的build.xml生成测试报告

    1.将写好的项目导出 在工程下会生成一个build.xml的蚂蚁图标的文件. 2.右击该文件,选择run as Ant build 其中的测试目录是可以选择的,如果涉及到顺序也可以调整顺序 3.执行后 ...

  2. springmvc+mybatis下载项目自带模板

    1.首先如果要获取javaweb项目中的文件在哪,用到的代码:request.getSession().getServletContext().getRealPath("/WEB-INF/d ...

  3. [转]解决LinearLayout中控件不能居右对齐

    在LinearLayout布局时使用右对齐(android:layout_gravity="right")控件对齐方式不生效,需要设置 android:layout_weight= ...

  4. 【转载】GDI 映像方式 之 SetViewportOrgEx 与 SetWindowOrgEx 解析

    SetViewportOrgEx 与 SetWindowOrgEx 解析 这两个函数,用来改变视端口和窗口的原点,并都具有改变轴的效果,以致(0,0)不再指左上角. 「视端口」是依据设备坐标(图素)的 ...

  5. 转: JMeter技巧集锦

    from:http://java.chinaitlab.com/tools/355421.html JMeter 是一个流行的用于负载测试的开源工具, 具有许多有用的功能元件,如线程组(thread ...

  6. java下发电子邮件demo

    在实际项目中会遇到需要使用邮件注册,或者是使用邮件找回密码等操作,需要使用到邮件发送功能. 其实邮件的发送主要是依赖于邮件协议,只要能实现邮件协议,那么发送邮件其实还是很容易的.这一步java类库已经 ...

  7. JSON对象长度和遍历方法(转)

    最 近在修改一个HTML页面的JS的时候遍历JSON对象,却怎么也调试不通过.怪这个HTML网页不知道用了什么方法禁止了js错误提示,刚开始的时候不 知道有这个问题,用chrome的开发人员工具都没发 ...

  8. 使用Emmet加速Web前端开发

    Emmet插件以前被称作为Zen Coding,是一个文本编辑器的插件,它可以帮助您快速编写HTML和CSS代码,从而加速Web前端开发.早在2009年,Sergey Chikuyonok写过一篇文章 ...

  9. XAMPP命令之LAMPP

    .wiz-todo, .wiz-todo-img {width: 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertica ...

  10. tcp 重组原理

    原文: http://blog.chinaunix.net/uid-21768364-id-4823449.html 1 .引言TCP/IP 协议现在已经广泛的被应用.数据在网络上应用 TCP/IP ...