2013-12-12 24 views
0

我有3個tableview有10行,拉動它後滾動它增加了下10行,但滾動到頂部,我希望它在同一行,這是以前。如何從iPhone中的同一行刷新tableview?

- (void)insertRowAtBottom { 
    int64_t delayInSeconds = 2.0; 
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); 
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 
    [self moreClicked]; 
    }); 
} 

回答

0

當拉發生了,你可以保存表視圖的最後一個索引路徑中的任何變量,然後使用下面的代碼來滾動表

NSIndexPath *lastIndexPath = [NSIndexPath indexPathForRow:(numberOfRows - 1) inSection:(numberOfSections - 1)]; 
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:lastIndexPath inSection:0]; 
[self.tableview scrollToRowAtIndexPath:indexPath 
       atScrollPosition:UITableViewScrollPositionTop 
         animated:YES]; 

對於滾動位置,你可以擁有的任何值列表。

UITableViewScrollPositionNone, 
UITableViewScrollPositionTop, 
UITableViewScrollPositionMiddle, 
UITableViewScrollPositionBottom 
0

有幾種方法可以在tableView中實現「分頁」。

一種方法是:假設你的tableView從一個對象數組填充 - 當你向下滾動,獲取下一個10個項目 - 只是新添加的數據添加到您的數據源數組,然後調用[self.tableview reloadData];

這會讓你確切地在你身邊。不需要滾動方法或動畫。

相關問題