滚动最后一个单元格问题

时间:2013-06-04 08:29:56

标签: ios scrollview tableview

我正在开发一款应用。其中有一个滚动视图。我在滚动视图上采取2表视图。我希望​​当我在第二个表中添加单元格键盘向上和表格视图中的最后一个单元格我将创建一个。我尝试下面的代码。但它不适合我。谁知道怎么做?我的应用程序具有与iTunes中“保持安全”应用程序相同的功能。

-(NSIndexPath *)lastIndexPath   
{

    NSInteger lastSectionIndex = MAX(0, [tvAlbumCell numberOfSections] - 1);
    NSInteger lastRowIndex = MAX(0, [tvAlbumCell numberOfRowsInSection:lastSectionIndex] - 1);

   return [NSIndexPath indexPathForRow:lastRowIndex inSection:lastSectionIndex];

}

-(void)goToBottom
{

     NSIndexPath *lastIndexPath = [self lastIndexPath];

    [tvAlbumCell scrollToRowAtIndexPath:lastIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
}

1 个答案:

答案 0 :(得分:0)

在goToBottom方法中尝试以下代码..

 CGPoint bottomOffset = CGPointMake(0, tvAlbumCell.contentSize.height - tvAlbumCell.bounds.size.height);
 [tvAlbumCell setContentOffset:bottomOffset animated:YES];
相关问题