UITableView, обнаруживающий последнюю ячейку

Как я могу обнаружить когда a UITableView был прокручен до нижней части так, чтобы последняя ячейка была видима?

17
задан Bartłomiej Semańczyk 10 May 2017 в 10:19
поделиться

2 ответа

Реализуйте метод tableView: willDisplayCell: forRowAtIndexPath: в своем UITableViewDelegate и проверьте, последняя ли это строка.

23
ответ дан 30 November 2019 в 09:59
поделиться

Внутри tableView: cellForRowAtIndexPath: или tableView: willDisplayCell: forRowAtIndexPath: вот так:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    ...

    NSInteger sectionsAmount = [tableView numberOfSections];
    NSInteger rowsAmount = [tableView numberOfRowsInSection:[indexPath section]];
    if ([indexPath section] == sectionsAmount - 1 && [indexPath row] == rowsAmount - 1) {
        // This is the last cell in the table
    }

    ...

}
40
ответ дан 30 November 2019 в 09:59
поделиться
Другие вопросы по тегам:

Похожие вопросы: