UITableview Cell 上的删除按钮会阻止自定义单元格图像
我对表格视图单元格进行了子类化,并向自定义单元格添加了几个标签和图像。
[self.contentView addSubview:lblDesc];
[self.contentView addSubview:imagesToDisplay];
当我编辑 tableView 并按“-”号时,删除按钮会出现在图像和其他内容的顶部。
其他一些应用程序会挤压单元格的内容以容纳删除按钮。
我该怎么做呢?
是否需要添加一个键值观察者 [单元格addObserver:self forKeyPath:@“showingDeleteConfirmation” 选项:NSKeyValueObservingOptionNew 上下文:NULL];
I have subclassed a tableview cell and added a couple of labels and images to the custom cell.
[self.contentView addSubview:lblDesc];
[self.contentView addSubview:imagesToDisplay];
When i edit the tableView and press the "-" sign the delete button appears on top of the image and other contents.
Some other apps squeeze the contents of the cell to accomodate the delete button.
How do i go about doing this??
Do i need to add a key value Observer
[cell addObserver: self forKeyPath: @"showingDeleteConfirmation"
options: NSKeyValueObservingOptionNew context: NULL];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
自动调整大小很简单 - 将其想象为网页。网页内容“流动”,它占用的空间与浏览器窗口提供的空间一样多。自动调整大小是相同的。有一些“掩码”告诉 UIKit 你希望你的内容如何调整以适应不同的帧大小。
因此,例如,如果您希望视图从右侧缩小或增大(例如,如果它是像表格单元格这样的左对齐内容),您可以像这样设置遮罩
:按位或运算,因此如果您希望它从右侧增长(如上所述)但也从底部增长,则可以将两者“或”在一起。
如果这对您不起作用(例如,您想要在屏幕上放置太多内容,并且需要删除某些元素等,或者您想要以某种方式不同于默认的动画),请考虑使用预先存在的方法在 UITableViewCell 中调用。 文档:
从 在单元格更改状态(正常->编辑或其他)之前调用,因此如果您需要执行任何特殊操作来将动画处理为编辑状态,那么这是您执行此操作的机会。文档指出:
Autoresizing is simple - think of it like a web page. Web content "flows", it takes up as much space as the browser window gives it. Autoresizing is the same. There are "masks" which tells UIKit how you want your content to adjust to different frame sizes.
So, for example, if you want your view to shrink or grow from the right side (if it were, for example, left-justified content like a table cell), you'd set the mask like this:
Autoresizing also works like a bitwise-OR operation, so if you want it to grow from the right (as above) but also grow from the bottom, you'd "OR" the two together.
In the case that this does not work for you (e.g. you want to put too much on the screen, and need to remove certain elements, etc, or you want to animate somehow differently than the default), consider using the pre-existing method calls in UITableViewCell. From the documentation:
This will be called right before the cell changes state (normal->editing or the other), so if you need to do anything special to handle the animation to the editing state, this is your opportunity to do so. The docs state:
您需要设置正确的
autoresizingMask
,以便当contentView
更改大小时按钮可以正确移动。You need to set the proper
autoresizingMask
so that your button moves properly when thecontentView
changes size.