Setting row height to 0 in a UITableView, but cell text is still showing overlapping

Currently, my line heights are configured like this:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == self.expandedSection || indexPath.row <= 3) { return 65; } return 0; } 

Essentially, I want the first 4 lines to be visible by default if the section is not in extended form, in which case all lines will be visible. I do this by setting the height of the lines of the first 4-65, and the rest - 0. The lines and their corresponding images are not displayed, however cell.textLabel and cell.detailTextLabel , which leads to their search as in the picture below.

How to disable both of them so that they do not appear at all for any lines in line 4?

enter image description here

+5
source share
2 answers

add this code to your cellForRowAtIndexPath

 if (indexPath.section == self.expandedSection || indexPath.row <= 3) { Cell.hidden = NO; } else{ Cell.hidden = YES; } 
+1
source

Add as answer:

make sure that the Click property for restrictions is set to YES either on the nib file or programmatically as cell.clipToBounds=YES

+1
source

Source: https://habr.com/ru/post/1207385/


All Articles