繁体   English   中英

UITableView - 如何滚动标题部分以及表格视图单元格?

[英]UITableView - How to Scroll header section along with table view cell?

我在uitableview中的每个部分都有动态单元格和动态页眉视图。 我们为tableview单元启用标题滚动吗?

将表格样式更改为xib中的Grouped。

如果我们必须为iOS 6和7显示相同的UI方法,我们在scrollview委托中使用了上述方法。

添加实际拥有的部分数量的两倍。 让偶数段只有段标题,而奇数段只应有没有段标题的行。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return double the number of sections.
return ([_arrSection count]*2);
}

和..

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//Even Sections will have only header and no rows 
if(section%2 == 0)
    return 0;

//Number of rows return only is the section is expanded else return 0
return [arrRowsForSpecificSection count];
}

和...

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
//Odd sections will have no header
if(section%2 == 1)
    return 0;

//for even sections
return HEIGHT_FOR_SECTION_HEADER;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{

//Odd section will have no header
if(section%2 == 1)
    return NULL;
//even section will have header
return Header_View;
}

因此,在运行时,它给人的印象是它是当前部分的标题,滚动而不固定在顶部。 流畅的动画!!!! 干杯

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM