iOS tableview의 sectionheader는 기본적으로 스크롤할 때 상위에 고정으로 잡혀있게 된다.
sectionheader 까지 스크롤이 가능하게 할 수 있는 코드가 있다.
물론 tableview를 scriollview로 감싸는 방법도 있지만..
다음 코드를 삽입하자. sectionheader까지 스크롤이 가능하다
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat sectionHeaderHeight = mTableView.sectionHeaderHeight;
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);
}
}
반응형
'IT > iOS' 카테고리의 다른 글
프로젝트 개발과정 (0) | 2014.08.05 |
---|---|
문자열에서 숫자만 추출하기 (0) | 2014.08.04 |
json 데이터에서 key, object 추출하기 (0) | 2014.08.01 |
NSMutableArray shuffle (배열 랜덤으로 섞기) (0) | 2014.07.23 |
Current View get subview (0) | 2014.06.03 |
64bit에서 컴파일시 objc_msgsend error (0) | 2014.05.15 |
[[NSUserDefaults standardUserDefaults] dictionaryRepresentation].allKeys (0) | 2014.03.04 |
iOS random integer (0) | 2014.02.05 |