TableView遇到的问题
1.所建立的TableView滑动不到底部的问题:
tableView继承scrollerView,当tableview开始建立的时候,会先计算每个cell的高度和每个headerview的高度、footerView的高度的总和就是contentSize的总和。当建立tableview的时候,frame的设置有时候会影响tableview的滑动,原因由于view的上面还有navigationbar的高度44和状态栏的高度20,若是tableview需要占整个屏幕的大小需要将控制器view的高度减去他们两的高度
2.当tableView有多个section的时候,section的视图随着tableview滑动到顶部时即卡在顶部不随其滑动
解决方法监控scrollerView的滑动
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat sectionHeaderHeight = 40;
if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
}
else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
}
}
但是此方法会造成tableview的滑动不顺畅
建议重写headview中的setframe的方法
- (void)setFrame:(CGRect)frame{
CGRectsectionRect = [self.tableViewrectForSection:self.section];
CGRectnewFrame =CGRectMake(CGRectGetMinX(frame),CGRectGetMinY(sectionRect),CGRectGetWidth(frame),CGRectGetHeight(frame)); [supersetFrame:newFrame];
}
此处的方法也会造成不顺畅
最好的办法是更改tableview的类型为group
TableView遇到的问题的更多相关文章
- iOS有关横向TableView的东西
之前看到Apple store里面有横向的tableview,当然也有可能是collectionview啦. 尤其是项目中只有一条那么需要横向滑动的东西,就没有必要使用庞大的collectionvie ...
- tableView显示第一个cell有偏移问题
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 0 ...
- [tableView reloadData] 和 runloop
需要[tableView reloadData]后需要立即获取tableview的cell.高度,或者需要滚动tableview,那么,直接在reloadData后执行代码是会有问题的. 断点调试感觉 ...
- 【代码笔记】iOS-一个tableView,两个section
一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...
- 【Swift】Alamofile网络请求数据更新TableView的坑
写这篇BLOG前,有些话不得不提一下,就仅当发发恼骚吧... 今天下午为了一个Alamofire取得数据而更新TableView的问题,查了一下午的百度(360也是见鬼的一样),竟然没有一个简单明了的 ...
- TableView 滑动收起键盘
self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag; 拖拽tableView就会收起键盘
- 关于TableView上有一段留白的解决方法
当cell的类型是plaint类型时 直接设置self.automaticallyAdjustsScrollViewInsets=NO; 还有要注意检查你自己设置的frame是否正确 当cel ...
- iOS监听tableView组头切换事件
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSIntege ...
- 【原】iOS学习之tableView的常见BUG
1.TableView头视图不随视图移动,头视图出现错位 错误原因:tableView的 UITableViewStyle 没有明确的声明 解决方法:在tableView声明的时候明确为 UITabl ...
- 两种让tableview返回顶部的方法
1. [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:_currentRow inSection:0] animat ...
随机推荐
- OpenBSD内核之引导MBR
MBR的介绍网上很多,没错,就那个最后以0x55AA结尾的512字节的引导块,OpenBSD提供了引导MBR实现:OpenBSD在x86上的引导过程为MBR --> PBR --> boo ...
- 关于app隐私设置跳转
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]] ...
- 动态获取R.drawable.xx资源
String imageName = "index_fragmen"+getColor();final int resId = context.getResources().get ...
- powerdesigner,eclipse整合安装
com.sybase.powerdesigner.eclipse.link path=D:\\dbs\\dbtools\\SAP\\PowerDesigner16
- merge,join,concat
merge交集 join并集 concat axis=0 竖着连 axis=1 横着连
- OC--编码建议
原文 http://www.cocoachina.com/ios/20151118/14242.html 本文是投稿文章,作者: IOS_Tips(微信公众号) “神在细节之中” Object ...
- ZTE and TP-Link RomPager - DoS Exploit
#!/usr/bin/env python # -*- coding: utf-8 -*- # Exploit Title: ZTE and TP-Link RomPager DoS Exploit ...
- Python 五个常用模块资料 os sys time re built-in
1.os模块 os模块包装了不同操作系统的通用接口,使用户在不同操作系统下,可以使用相同的函数接口,返回相同结构的结果. os.name:返回当前操作系统名称('posix', 'nt', ' ...
- python网络编程【一】
TCP/IP 是标准的协议,它可以使用世界范围内的计算机通过Internet或本地的网络通信 1.编写一个TCP客户端程序 #!/usr/bin/env python import socket, s ...
- nginx 模块讲解
1. 通用配置选项: --prefix=<path> 指定Nginx的安装路径,所有其他的路径都要依赖于该选项 --sbin-path=<path> ...