Ios 如何滚动uitableview和顶部的节标题,可见并滚动到
我有Ios 如何滚动uitableview和顶部的节标题,可见并滚动到,ios,objective-c,xcode,uitableview,Ios,Objective C,Xcode,Uitableview,我有UITableview,其中包含多个带有样式组的部分,以及轻型自定义标题视图 滚动后,标题不会粘在顶部,且不可见 我需要滚动UITableview并在顶部视图中粘贴节头,使其可见,如电话簿 如何使之成为现实 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerView = [[UIView alloc] initWithFram
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;
}
UITableViewStyleGrouped=节页眉和页脚不浮动 UITableViewStylePlain=滚动表视图时,任何节页眉或页脚都显示为内联分隔符和浮动 您只需将UITableViewStyle更改为UITableViewStylePlain 然后,若要以编程方式滚动到特定的行和节,可以使用下面的UITableViewMethod
//Scroll to First row in 2 section
[yourTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1]
atScrollPosition:UITableViewScrollPositionTop animated:YES];
对于没有行的节,解决方案不起作用