Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize UITableViewCell content when delete button shows up

Is there any way to use autoresizing masks to move my content so that the delete button doesn't cover it up? Googling has told me that I need to set an autoresizing mask of UIViewAutoresizingFlexibleRightMargin on my subview. It seems to me like UIViewAutoresizingFlexibleWidth would actually make more sense; though I've tried them both and neither works.

The view that I am trying to shrink is just a label that is a subview of the cell's contentView. I am unsure if the contentView itself automatically resizes when the delete button shows up; but it seems like it isn't; otherwise my autoresizing mask should have worked.

If the presence of the delete button doesn't cause any views to be resized; is there anyway that I can do this manually?

like image 622
GendoIkari Avatar asked Feb 25 '23 15:02

GendoIkari


1 Answers

You should use UIViewAutoresizingFlexibleLeftMargin.

Here's why. You want your contents to move to the left, basically making it seem like the delete button is pushing the contents to the left, out of it's way. flexibleLeftMargin basically means your UILabel will stay fixed to the right side of your contentView. The reason you want this, is because the delete button actually causes your contentView to shrink it's width.

The autoresizingmask of your UILabel refers to how it behaves inside the contentView, not the cell.

Give it a try, it should work.

like image 51
Sahil Avatar answered Mar 15 '23 23:03

Sahil