'UITableView' такой же, как 'UIScrollView' в методе 'scrollViewDidScroll'.
Таким образом, его легко эмулировать бесконечную прокрутку.
двойной массив так, чтобы голова и хвост соединяются вместе, чтобы эмулировать круглый стол
использовать мой следующий код, чтобы пользователю переключаться между 1-й части удвоенного стола и 2-й части удвоенного стола, когда они, как правило для достижения начала или конца таблицы.
:
/* To emulate infinite scrolling...
The table data was doubled to join the head and tail: (suppose table had 1,2,3,4)
1 2 3 4|1 2 3 4 (actual data doubled)
---------------
1 2 3 4 5 6 7 8 (visualising joined table in eight parts)
When the user scrolls backwards to 1/8th of the joined table, user is actually at the 1/4th of actual data, so we scroll instantly (we take user) to the 5/8th of the joined table where the cells are exactly the same.
Similarly, when user scrolls to 6/8th of the table, we will scroll back to 2/8th where the cells are same. (I'm using 6/8th when 7/8th sound more logical because 6/8th is good for small tables.)
In simple words, when user reaches 1/4th of the first half of table, we scroll to 1/4th of the second half, when he reaches 2/4th of the second half of table, we scroll to the 2/4 of first half. This is done simply by subtracting OR adding half the length of the new/joined table.
*/
-(void)scrollViewDidScroll:(UIScrollView *)scrollView_
{
CGFloat currentOffsetX = scrollView_.contentOffset.x;
CGFloat currentOffSetY = scrollView_.contentOffset.y;
CGFloat contentHeight = scrollView_.contentSize.height;
if (currentOffSetY < (contentHeight/8.0)) {
scrollView_.contentOffset = CGPointMake(currentOffsetX,(currentOffSetY + (contentHeight/2)));
}
if (currentOffSetY > ((contentHeight * 6)/ 8.0)) {
scrollView_.contentOffset = CGPointMake(currentOffsetX,(currentOffSetY - (contentHeight/2)));
}
}
P.S. - Я использовал этот код в одном из моих приложений под названием NT Time Table (Lite). Если вы хотите просмотреть предварительный просмотр, вы можете проверить приложение: https://itunes.apple.com/au/app/nt-time-table-lite/id528213278?mt=8
Если ваша таблица иногда может быть слишком короткой, в начале вышеприведенного метода вы можете добавить логику if, чтобы выйти из метода, когда число данных указано для пример менее 9.
Если вы NSLog 'self.newsFeedData_' до и после вызова' [самоуправления .newsFeedData_ addObjectsFromArray: self.newsFeedData _]; 'это то же самое? (Возможно, начните с выведения '[self.newsFeedData_ count]' и посмотрите, увеличилось ли количество записей в массиве? – runmad
Вот демо бесконечного UITableView в Swift: https://github.com/i-schuetz/ tableview_infinite – Ixx
Я добавил [ответ здесь] (http://stackoverflow.com/a/42902171/882630), который использует таблицу UITableViewDelegate View (_: будет отображать: для строки в:) метод экземпляра очень просто. – lukkea