2011-04-12 60 views
0

基本上我有完整的默认行为与节标题。我只希望用户可以将最后一节标题滚动到最上面。有没有办法让最后一节的标题滚动到顶部?

例如,您有一张表,其中有44个像素高度的行。表格的高度为〜500像素。 如果LAST部分只有2个条目,您将无法将此部分滚动到表格的最顶部,从而将上一部分标题保留在顶部,最后部分标题保留在屏幕中间,揭示了最后一节的最后2行。

我喜欢它,所以用户可以将最后一节标题滚动到顶部 - 如果最后一节仅包含几行,则为表格的下半部分留下空行(如有必要)。

这是可能的吗?

回答

0

是的,它是.........

你所要做的仅仅是设置contentInset为表视图什么....

[yourTableView setContentInset:UIUIEdgeInsetsMake(0,0,yourScrollableHeight,0)]; 

**更新 *** 这里是要知道在最后一节电池的过程......(cellForRowAtIndexPath代码)

int numberOfSections = [yourTableView numberOfSections]; 
if(it's last section... [indexPath.section == numberOfSections-1]) 
{ 
    int numberOfRowsInLastSection = [yourTableView numberOfRowsInSection:indexPath.section]; 
    //default height of row is .. 44px... 
    // now I hope you can calculate this...... 
    //and here use above line of code for setting scroll behavior... 
} 

谢谢,

+0

这__作品。看起来,要使用这个,我必须精确地知道有多少行我是整个表格的高度 - 这是一个问题,有时最后一节只能有2行,或者有时它只能有1行...或3等。 – 2011-04-12 15:03:17

+0

您可以从上述更新的代码中获得所需的信息...谢谢 – Ravin 2011-04-12 15:53:55

相关问题