当删除按钮显示时调整UITableViewCell内容的大小 [英] Resize UITableViewCell content when delete button shows up

查看:140
本文介绍了当删除按钮显示时调整UITableViewCell内容的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用自动调整大小的屏幕来移动我的内容,以便删除按钮不会覆盖它?谷歌告诉我,我需要在子视图上设置 UIViewAutoresizingFlexibleRightMargin 的自动调整掩码。在我看来,像 UIViewAutoresizingFlexibleWidth 实际上会更有意义;虽然我已经尝试过它们但都不起作用。

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.

我试图缩小的视图只是一个标签,它是单元格contentView的子视图。我不确定当删除按钮出现时,contentView本身是否会自动调整大小;但似乎不是;否则我的自动调整掩码应该有效。

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?

推荐答案

您应该使用UIViewAutoresizingFlexibleLeftMargin。

You should use UIViewAutoresizingFlexibleLeftMargin.

这就是原因。你希望你的内容向左移动,基本上使得看起来像删除按钮正在将内容推向左边。 flexibleLeftMargin基本上意味着你的UILabel将保持固定在contentView的右侧。你想要这个的原因是因为删除按钮实际上导致你的contentView缩小它的宽度。

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.

UILabel的自动调整掩码指的是它在contentView中的行为,而不是细胞。

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

试一试,它应该有效。

这篇关于当删除按钮显示时调整UITableViewCell内容的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆