2013-06-04 80 views
0

我正在開發一個應用程序。在那裏我有滾動視圖。我在滾動view.i想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]; 
} 

回答

0

嘗試以下在goToBottom方法代碼..

CGPoint bottomOffset = CGPointMake(0, tvAlbumCell.contentSize.height - tvAlbumCell.bounds.size.height); 
[tvAlbumCell setContentOffset:bottomOffset animated:YES]; 
相關問題