Created
November 13, 2012 11:56
-
-
Save mactive/4065399 to your computer and use it in GitHub Desktop.
如何让 UITableView 的 headerView跟随 cell一起滚动
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//The way I solved this problem is to adjust the contentOffset according to the contentInset in the //UITableViewControllerDelegate (extends UIScrollViewDelegate) like this: | |
- (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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment