I have a custom (subclass) UITableViewCell that contains several UILabels, UIButton and NSBlock as properties. This subclass is called ExploreCell . Two properties are UILabels and are called waitLabel and lastUpdateLabel respectively.
When the contents of lastUpdateLabel is zero or empty, i.e. @"" , I need to move waitLabel vertically down (on the Y axis) by 10 pixels. I do this by checking some objects in an NSDictionary , as shown in the following code, which I put in the -tableView:cellForRowAtIndexPath: method -tableView:cellForRowAtIndexPath:
CGRect frame = cell.waitLabel.frame; if ([[venue allKeys] containsObject:@"wait_times"] && ([[venue objectForKey:@"wait_times"] count] > 0)) { frame.origin.y = 43; } else { frame.origin.y = 53; } [cell.waitLabel setFrame:frame];
However, this code works intermittently, and trying to call -setNeedsLayout still does not work. With interruptions, I mean that after scrolling several times, one or two cells that meet the criteria for moving the cell source by 10 pixels actually have a waitLabel frame.
Please tell me why this is happening and how it can be fixed.
source share