0

アプリを開発しています。そこにはスクロールビューがあります。そして、スクロールビューで2つのテーブルビューを取得しています。2番目のテーブルにセルを追加すると、キーボードが上になり、テーブルビューの最後のセルが表示されます。以下のコードを試しましたが、うまくいきません。誰でもこれを行う方法を知っていますか?. 私のアプリには、iTunes の「keep safe」アプリと同じ機能があります。

-(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];
}
4

1 に答える 1

0

goToBottom メソッドで次のコードを試してください。

 CGPoint bottomOffset = CGPointMake(0, tvAlbumCell.contentSize.height - tvAlbumCell.bounds.size.height);
 [tvAlbumCell setContentOffset:bottomOffset animated:YES];
于 2013-06-04T09:43:27.540 に答える