iOS 10과 더불어 업데이트 된 Xcode 8.x 버전으로 기존 앱을 빌드 했을 때,
기존에 tableView Header를 커스텀 뷰로 개발하였을 때 section header view가 보이지 않는 문제가 생긴다.
해당 문제는 기존에는 디폴트 높이를 설정하지 않아도 알아서 높이가 들어 갔는데 이번 버전부터는 해당 기능이 삭제가 된듯(....)
앞으로 점점 스토리보드 위주로 갈 것이라고 생각했는데 이번 건은 오히려 스토리보드의 역할이 줄어든 듯한 느낌.. 다른 이유가 있겠지.
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 30;
}
위 코드를 추가 하여 높이를 지정해주면 다시 section header view가 나타난다!
이 사실을 알기 전까지는 커스텀 헤더 뷰 지원이 중단 된 줄 알았음 ㅠ_ㅠ
아래는 대략적인 헤더 뷰 생성 예제 코드
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *customTitleView = [ [UIView alloc] initWithFrame:CGRectMake(10, 0, 300, 44)];
UILabel *titleLabel = [ [UILabel alloc] initWithFrame:CGRectMake(20, 0, 300, 44)];
if(section == 0)
{
titleLabel.text = @"섹션1";
titleLabel.textColor = UIColorFromHEX(0x008080);
}
else if(section == 1)
{
titleLabel.text = @"섹션2";
titleLabel.textColor = UIColorFromHEX(0xFFCC66);
}
else
{
titleLabel.text = @"섹션3";
titleLabel.textColor = UIColorFromHEX(0x1E90FF);
}
titleLabel.font = [UIFont fontWithName:@"NanumBarunGothic" size:16];
titleLabel.backgroundColor = [UIColor clearColor];
[customTitleView addSubview:titleLabel];
return customTitleView;
}
'프로그래밍 > iOS - OBJC' 카테고리의 다른 글
SMS 컴포넌트 호출하기 (2) | 2016.10.31 |
---|---|
TableView Cell에서 다음 화면으로 데이터 넘기기 (0) | 2016.07.25 |
iOS NSTimer 호출하기 (1) | 2016.05.12 |
맥 OS X PhoneGap 설치 (0) | 2016.04.27 |
iOS에서 위치정보 사용 동의 받기 (0) | 2016.03.10 |