不能单独滚动每个部分。然而,根据你的描述,听起来你的第一节不是真正的一节,实际上应该是第二节的标题。为节创建标题时,标题将始终保持可见。要创建自定义视图节,需要实现UITableViewDelegate协议中定义的viewForHeaderInSection和heightForHeaderInSection。
下面是一个例子
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 60;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *myHeader = [[[UIView alloc] initWithFrame:CGRectMake(0,0,60,320)] autorelease];
myHeader.backgroundColor = [UIColor redColor];
UILabel *myLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0,0,30,150)] autorelease];
myLabel.text = @"Testing header view";
[myHeader addSubView:myLabel];
return myHeader;
}
通过这种方式,您可以创建一个表视图,其中包含一个节和该节的标题,即使在滚动表时,该标题也将保留在视图中。