ale*_*ock 8 xcode objective-c uitableview ios
我有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;
}
Run Code Online (Sandbox Code Playgroud)
Vij*_*com 19
UITableViewStyleGrouped =节页眉和页脚不浮动.
UITableViewStylePlain =任何节页眉或页脚显示为内联分隔符,并在滚动表视图时浮动
您只需将UITableViewStyle更改 为UITableViewStylePlain
然后以编程方式滚动到特定的行和节,您可以在UITableViewMethod方法下使用此方法.
//Scroll to First row in 2 section
[yourTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1]
atScrollPosition:UITableViewScrollPositionTop animated:YES];
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
13714 次 |
| 最近记录: |