滑动删除将 UITableViewCell 移至左侧
我使用自定义代码来创建显示在 UITableView 上的单元格。滑动行时,删除按钮会按预期出现在单元格的最右侧。但是,它会导致单元格的内容向左移动(部分移出屏幕)。使用框架中内置的单元时,不会发生这种行为。
I use custom code to create cells that get displayed on a UITableView. When a row is swiped, the delete button appears on the far right of the cell as expected. However it causes the contents of the cell to move to the left (partly off screen). This kind of behaviour didn't happen when using the cells that are built in to the framework.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
UIView
属性autoresizingMask
允许您指定子视图在其超级视图(在本例中为UITableViewCell
的contentView< /code>) 被调整大小。
请参阅 查看 iOS 编程指南了解更多信息。
The
UIView
propertyautoresizingMask
allows you to specify how your subviews should behave when their superview (in this case theUITableViewCell
'scontentView
) gets resized.See the View Programming Guide for iOS for more information.
不是因为你的内容绑定到了右边缘吗?
Isn't it because your content is bound to the right edge?
尽管这个答案可能为时已晚,但我相信问题是由于您碰巧通过编写以下内容直接将内容添加到单元格中:
这碰巧很好;但是,您的内容将受到单元格内发生的任何更改的影响。另一方面,如果您希望视图在单元格发生任何其他情况时保持不变,则必须将内容添加为单元格 contentView 的子视图:
我确实希望这会有所帮助。
干杯!
Although this answer may be too late, I believe the problem is due to the fact that you happen to be adding your content directly to the cell by writing something like:
This happens to be good; however, your content will be affected by any change that takes place within the cell. If, on the other hand, you want your views to remain intact while anything else happens to the cell, you must add your content as subviews of the cell's contentView:
I do hope this helps.
Cheers!