Is it possible to keep the contentView.frame always the same, regardless of tableView.editing? I already tried to override layoutSubviews and willTransitionToState but those options fizzled out too. I can’t seem to be able to change the width of the contentView. Or maybe my approach ist just plain impossible …
Maybe there is another way to solve this.
The behaviour I want to achieve is the following: I want the standard textLabel of a UITableViewCell to be always indented and not change position when the tableView enters editing mode. The problem I will probably face is that the behaviour of the detailTextLabel will have to be corrected (e.g. truncation of text if textLabelcontent is too long). The reason why I don’t want to implement my own UILabelis because a custom subviews will decrease the scrolling performance by a significant amount.
I hope that anyone already implemented something like this in their UITableViewand could show me a solution to this tedious problem. Thanks in advance!
EDIT: I’m dealing with a UITableView in plain and not grouped style.
Luckily, iOS is perfectly equipped to keep whatever value constant.
This (ugly) piece of code will keep the frame fixed to whatever value has
origin.x==0. This is easily adapted to your particular needs.This will only allow the frame to change to values with an
origin.x==0. Remove theNSLog()lines for Release builds.I have tested this for a few minutes and haven’t seen any side effect.