UITableViewCell indentation funkiness

192 Views Asked by At

No existing questions quite get at what is happening in my app.

Indentation levels in my UITableViewCell subclass are sporadically either at 1 or 0. The text in the cell will either indent or hug the left margin (seemingly at random) as cells are en- and de-queued. I set the level in cellForRow:, I set the level in my subclass's configure: method, I implement indentationLevelForRow:. None of these has a noticeable effect.

The one thing I can reproduce is that the indentation collapses (level <- 0) when I touch a cell. Another touch doesn't toggle it. I write 'touch' here because this happens even if willSelect: returns nil; Scrolling after these touches sporadically resets levels to 1.

The one thing that might be the problem is that the content view contains a single instance of a 3rd party UILabel subclass TTTAttributedLabel. I don't know much about this code, but there is method, setText:afterInheritingLabelAttributesAndConfiguringWithBlock: which block completion/callback is implemented and could be affecting things. But that doesn't seem to be the case, because nilling the callback makes no noticeable improvement.

2

There are 2 best solutions below

0
On BEST ANSWER

I wound up reimplementing the whole view in a Storyboard, and after quite a bit of trial and error with AutoLayout, managed to get the whole thing to work without any bugginess.

1
On

The documentation doesn't say with certainty either way, but I would not assume that tableView:indentationLevelForRowAtIndexPath: applies to a custom subview, like TTTAttributedLabel in your case. That is to say, I would assume it only impacts the cell's standard subviews (textLabel, imageView, etc).

If you require custom indentation levels for custom subviews, I expect you'll need to implement that yourself. You can certainly continue to implement that delegate method to centralize the logic, but you'll likely need to use the result of that method when laying out your cell.