UITableViewCell-控制移动

发布于 2024-12-28 15:54:53 字数 524 浏览 2 评论 0原文

编辑 UITableView 时,我提供了移动单元格以重新排序数据的选项。但是,表格中最上面的两个单元格提供了有关表格中所有单元格的信息,我不希望用户能够将信息单元格移动到该部分。这是问题的图片:

用户不应该能够拖动标题为“这很糟糕!!!”的单元格进入包含“总计:”和“新组...”单元格的部分。

用户不应该能够拖动标题为“这很糟糕!!!”的单元格进入包含“总计:”和“新组...”单元格的部分。有没有办法控制这个功能?我还没有看到执行此操作的委托方法,但我可能错过了一个。

编辑:哎呀!我刚刚看到其他人在 SO 上问了同样的问题,所以我将发布链接并关闭这个问题。感谢@fzwo 的帮助。

如何将 UITableView 行重新排序限制为某个部分

When editing my UITableView, I give the option to move cells to reorder the data. However, The top two cells in the table are cells that give information about all of the cells in the table, and I dont want the user to be able to move information cells into that section. Here is a picture of the problem:

The user shouldn't be able to drag the cell titled 'This is bad!!!' into the section with the 'Total:' and 'New Group...' cells.

The user shouldn't be able to drag the cell titled 'This is bad!!!' into the section with the 'Total:' and 'New Group...' cells. Is there a way to control this functionality? I haven't seen a delegate method that does this, but I could have missed one.

Edit: oops! I just saw that someone else has asked the same question on SO, so I'm going to post the link and close this question. Thanks @fzwo for your help.

How to limit UITableView row reordering to a section

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

徒留西风 2025-01-04 15:54:53

UITableViewDelegate 中的 tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath: 就是您要查找的内容。

在您的具体情况下,您还可以在实际的 tableView.tableHeaderView 中显示标题信息。它像普通单元格一样滚动,但不是单元格。从用户界面的角度来看,它可能也有意义,因为它与普通的单元格内容不同。

tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath: from UITableViewDelegate is what you're looking for.

In your concrete case, you could also display the header information in the actual tableView.tableHeaderView. This scrolls like an ordinary cell, but isn't a cell. It would probably also make sense from a UI perspective, because it is something different than your ordinary cell content.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文