【发布时间】:2014-08-21 06:55:26
【问题描述】:
我有 UITableview 有多个带有样式组的部分,以及轻量级的自定义标题视图
滚动后,标题不粘在顶部,不可见
我需要滚动 UITableview 并将部分标题粘贴在顶部视图中并且可见,例如电话簿
如何制作?
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320,50)];
UILabel *labelHeader = [[UILabel alloc] initWithFrame:CGRectMake(20, 5, 120, 40)];
labelHeader.text = [[_groups objectAtIndex:section] objectForKey:@"nameExerciseGroup"];
labelHeader.textColor = [UIColor blackColor];
[labelHeader setFont:[UIFont systemFontOfSize:20]];
[headerView addSubview:labelHeader];
return headerView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 50;
}
【问题讨论】:
标签: ios objective-c xcode uitableview