ios - 编辑模式下的 UITableViewCell 子类布局

标签 ios swift uitableview

当 tableView 进入编辑模式时,我在自定义单元格的布局中看到一些非常奇怪的行为。

内容 View 似乎变得非常小,并移至单元格的右侧。

example image 左侧是正常模式下的单元格,右侧是编辑模式下的单元格。

有人知道这里会发生什么吗?

编辑:

可以从 dropbox here 获取此问题的非常简化版本的代码

最佳答案

评论后编辑:

尝试注释掉下面的行。

cell.layoutMargins = UIEdgeInsets(top: 0, left: UIScreen.mainScreen().bounds.width, bottom: 0, right: 0)

From Apple Documentation

当行被重新定位时...

... The delegate assigns the controls in tableView:cellForRowAtIndexPath: by setting the showsReorderControl property of UITableViewCell objects to YES

因为您在cellForRowAtIndexPath中再次设置layoutmargins,所以它可能会覆盖形成的附件 View 并重新绘制单元格布局。

关于ios - 编辑模式下的 UITableViewCell 子类布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37037316/

相关文章:

ios - Hook 主页按钮按下

android - 处理来自多个服务器的远程推送通知

ios - 我无法将 NSLogger 成功集成到我的应用程序中

ios - 防止 UIView 在 Swift 中溢出到 SuperView 之外

ios - Xcode 4.2 中的存档、方案设置和代码签名

Swift:如何在不重新加载数据的情况下重新加载 UITableViewCell 中的行高

xcode - 如何访问另一个类中的变量?

ios - TableView :viewForHeaderInSection: default value?

ios - 如何更改已点击的 UITableViewCell 中的 UILabel

ios - 如何使搜索栏不随表格 View 一起滚动?