TableView那点事
来源:互联网 发布:巨峰科技有限公司软件 编辑:程序博客网 时间:2024/06/07 17:27
强烈推荐StackOverflow,所有的问题都是在那找到的答案。
问题1:UITableViewStyleGroup如何让Header、Footer高度为0?
// 我们都知道,仅仅在代理里面写一个返回0是不行的,系统会返回一个默认高度的HeaderView;- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ DLog(@"子类需要重写 height for Header 方法!"); return CGFLOAT_MIN;}
So…是不是还需要在viewForHeaderInSection
里面做文章呢?对的,要这么写:
// 高度为0的时候return nil 就会让高度为0了。 (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ if ([self tableView:tableView heightForHeaderInSection:section]==0.0) { return nil; }else{ UIView *aView = [[UIView alloc] init]; return aView; } }}
问题2:scrollViewDidEndScrollingAnimation
和scrollViewDidEndDecelerating
的区别
2.1scrollViewDidEndScrollingAnimation
:
这货是系统的scroll动画:(如:
setContentOffset,
reloadData,
UITableViewScrollPositionTop
…
)
这些才会触发。特别声明:如果你在这些动画的外层使用了隐式动画如:[UIView animateWithDuration: animations:
是不会触发该代理的,因为隐式动画不会去调用scrollView的setContentOffset方法,而是走的setFrame、translation等方法。
2.2scrollViewDidEndDecelerating
:
这货是你手动滑动一下scrollView而且手要离开屏幕让scrollview自己滚动,在scrollView减速停止的时候触发。
假如你的手一直在scrollView上面未曾离开,手离开的时候scrollView没有运动迹象,那是不会触发该代理的。
问题3:如何更改(void)scrollToRowAtIndexPath: atScrollPosition: animated:
的动画时间?
相信看过问题2的朋友已经直到了答案。
对,就是用隐式动画:
[UIView animateWithDuration:0.5 animations:^{ [tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO]; }];
问题4:自定义cell xib文件报如下错误:
那请你一定要确保你xib文件中的所有控件都没有设置Class。
如图,我就是不小心给我的一个view控件设置了Class,还TM设错了。。。(宝宝想脱单了可能..)
然后就各种崩…
只要把不该有class的控件去掉class关联就好了。
就BB这么多,毕竟中秋小假期,不能光写博客,还得学习别的东东~
- TableView那点事
- tableView 那点事 及 导航栏字体颜色
- 关于tableView分割线的那点事
- 那年--那兔--tableView 那些事
- 面试那点事
- 公司那点事
- 编程那点事!!
- 公务员那点事
- 毕业那点事
- JVM 那点事
- C++那点事
- 【粗心】那点事
- 【春运】那点事
- 内存那点事
- 程序员那点事
- Ext那点事
- Ext那点事
- 学习那点事
- Android 中AppCompatActivity和Activity中隐藏标题栏的方式
- Qt使用QGraphicsView实现滑动窗体效果
- 文章标题
- Yii2.0 路由
- vim gcc gdb make的使用
- TableView那点事
- 51nod-1136 欧拉函数
- lightoj 1099 - Not the Best(次短路)
- 【LeetCode-111】Minimum Depth of Binary Tree(C++)
- ubuntu16.04 ftp 连接 提示 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
- UNIX网络编程笔记 第十一章 名字与地址转换
- Android动画之视图动画
- 馒头,不!月饼引起的惨案
- 类的抽象和封装