0

titleForHeaderInSection "Мои диеты" смещен вверх (некорректно отображается)введите сюда описание изображения

если скролить, то все становится на место.

введите сюда описание изображения

Вод код:

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {

    if (section == 0) {
        return nil;
    } else if (section == 1) {
        return @"Создать диету";

    } else if (section == 2) {
        if ([tableView.dataSource tableView:tableView numberOfRowsInSection:section] > 0) {
            return @"Мои диеты";
        } else {
            return nil;
        }
    } else {
        return @" ";
    }
    return nil;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    if (section == 0) {
        return 0;
    } else if (section == 1) {
        return [self.menuItems count];

    } else if (section == 2) {

        NSUInteger frcSection = section - 2;
        id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:frcSection];

        self.sectionInfoCount = [sectionInfo numberOfObjects];
        [self enabledEditButton:self.sectionInfoCount];

        return self.sectionInfoCount;
    } else {
        return 1;
    }
    return 0;
}

Загрузка данных в таблицу приводится из CoreData.

Пробовал делать [self.tableView reloadData] - не помогает.

Как решить данную проблему?

1
  • Не использованы ли методы вроде -register[Class|Nib]:forHeaderFooterViewReuseIdentifier:? И какие ещё методы UITableViewDataSource реализованы делегатом?
    – bteapot
    29 июн 2016 в 9:56

1 ответ 1

1

Я бы сделал отдельный прототип ячейки, который бы состоял только из Label и backg color, затем поместил бы его в viewForHeaderInSection: задав ему heightForHeaderInSection:

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.