user754905
user754905

Reputation: 1809

No Indentation in Custom TableCell while Editing TableView

I've spent a lot of time today trying to figure out how to get my custom table cell (built using XIB) to stop indenting when in editing mode.

I have looked all over the place, Examples: Prevent indentation of UITableViewCell (contentView) while editing and How can I change the amount of indentation on my custom UITableViewCell while editing? but seem to be running into the same problem that the OP ran into with the cell jumping around.

Has any one found a better way to solve this problem?

Basically I have a CustomTableCell, and when I enter Editing mode on that cell, I want the cell to stay where it is with no indentation.

Thanks for the help!

Upvotes: 3

Views: 3258

Answers (4)

lopes710
lopes710

Reputation: 415

You should use the tableView:shouldIndentWhileEditingRowAtIndexPath: delegate method to return No. If that doesn´t work go to the .xib and open the utilities view (the one in the right). From there disable "use Autolayout" in the file inspector tab and disable "indent while editing" in the attributes inspector.

Upvotes: 3

akaru
akaru

Reputation: 6317

You should use the delegate method tableView:shouldIndentWhileEditingRowAtIndexPath: and return false.

From the docs: "Asks the delegate whether the background of the specified row should be indented while the table view is in editing mode."

Upvotes: 2

user754905
user754905

Reputation: 1809

Interesting. I managed to make the solution posted in the links work using a hack: In layoutSubviews I just did self.indentationWidth = 0.0001; :. Not the cleanest solutions but it works.

Upvotes: 1

Drew C
Drew C

Reputation: 6458

I've discovered that if you put a custom cell's subviews on a UIView that is between approximately 300 and 320 points wide, and then add said subview to the cell's content view, it will not move the subview upon triggering editing mode.

Upvotes: 0

Related Questions