2016-01-13 2 views
1

Я хочу, чтобы верхние и нижние колонтитулы для разделов моего UITableView, чтобы быть скрыты, и я в настоящее время установки их так:Как скрыть заголовки моих разделов UITableViews программно?

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { 
    return 0; 
} 

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { 
    return 0.0; 
} 

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { 
    return nil; 
} 

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { 
    return nil; 
} 

Как вы можете видеть на скриншоте, это успешно скрыли колонтитулы, но а не заголовки (показаны серым цветом). Чего не хватает?

enter image description here

+0

Является ли это DUP? http://stackoverflow.com/questions/5164291/programmatically-remove-the-header-of-uitableview-and-automatically-resizes- –

ответ

1

Метод heightForHeaderInSection не работает с 0. Попробуйте это:

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { 
    return 0.0001f; 
} 
+0

Бинго, спасибо! Странно, что 0 не работает, но это число. – TheDudeGuy

Смежные вопросы