Чтобы узнать, является ли это последней строкой в разделе, вызовите tableView:numberOfRowsInSection:
для делегата источника данных (предположительно, это self
, поскольку вы используете метод tableView:cellForRowAtIndexPath:
). Если значение, возвращаемое этим методом, равно indexPath.row+1
, вы находитесь в последней строке. Если дополнительно indexPath.row == 0
, вы находитесь в единственном ряду. Если indexPath.row == 0
, но tableView:numberOfRowsInSection:
вернул число, отличное от 1, вы смотрите на первую строку в разделе.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger count = [self tableView:tableView numberOfRowsInSection:indexPath.section];
BOOL first = indexPath.row == 0;
BOOL last = indexPath.row+1 == count;
if (first && last) {
NSLog(@"The only cell in section %d", indexPath.section);
} else if (first) {
NSLog(@"The first cell in section %d", indexPath.section);
} else if (last) {
NSLog(@"The last cell in section %d", indexPath.section);
} else {
NSLog(@"Nothing special...");
}
// Do the rest of your work
}