去除UITableView的粘滞性(stick)

http://stackoverflow.com/questions/9602966/uitableview-with-static-headers

 

http://stackoverflow.com/questions/664781/change-default-scrolling-behavior-of-uitableview-section-header

 

关键代码段:

 

Below is one solution:

-(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);}elseif(scrollView.contentOffset.y>=sectionHeaderHeight){
       scrollView.contentInset =UIEdgeInsetsMake(-sectionHeaderHeight,0,0,0);}}

However it will have a bit of flicker while header reaches to top.

One more soultion is to make Grouped table view.

One more thing is to add a section with zero rows at the top and simply use the footer of the previous section as a header for the next.

posted @ 2012-12-10 14:35  我的程序人生  阅读(373)  评论(0编辑  收藏  举报