即使在 tableView 重新加载数据后,UITableView 选择也会突出显示

发布于 2024-08-10 11:35:08 字数 262 浏览 4 评论 0原文

我上面有一个 UIScrollView 和一个 UITableView 。 UITableView 有 4 个单元格。我使用 UIPageControl 进行分页。

当用户选择时,单元格会突出显示,当用户滚动到下一页时,单元格会保持突出显示。

我尝试了 [tableView reloadData] ,在调用后我仍然可以看到 UITableView 上选定的行,但我不明白。

我应该重画 UIScrollView 吗?

有什么办法可以清除选择吗?

I have a UIScrollView and a UITableView on it. The UITableView has 4 cells. I use UIPageControl for pagination.

When user selects, the cell gets highlighted and when the user scrolls to the next page the cell stays highlighted.

I tried [tableView reloadData] and after the call I could still see the selected row on the UITableView which I do not understand.

Should I redraw the UIScrollView?

Is there any way of clearing up the selection?

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

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

发布评论

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

评论(2

黎夕旧梦 2024-08-17 11:35:08

当您将表视图包含在另一个视图中时,我已经看到了这种行为。如果这样做,您需要手动清除当前选择。您可以通过调用以下命令来完成此操作:

[tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:animated];

其中“动画”设置以满足您的需要。

如果您直接包含表格视图(正如另一个人指出的那样,您的表格视图本身已经滚动得很好,可能会使您的 UIScrollView 变得不必要并且启动时形式不好),这种行为是自动的。

I've seen this behavior when you include a table view within another view. If you do this, you need to manually clear up the current selection. You can do this by calling the following:

[tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:animated];

where 'animated' is set to fit your needs.

If you include the table view directly (as another person noted, you a table view already scrolls just fine all by itself, likely making your UIScrollView unnecessary and bad form to boot), this behavior is automatic.

栩栩如生 2024-08-17 11:35:08

您是否使用 UIScrollView 和/或 UIPageControl 来滚动 UITableView? UITableView 不需要其中任何一个来滚动。

从你的描述来看,听起来你没有正确地重复使用细胞。

放置一些代码,我们将有更多的工作要做。您可能需要向我们展示您的 UITableView 子类 .m 文件。

Are you using a UIScrollView and/or UIPageControl to scroll the UITableView? UITableView doesn't need either of those for scrolling.

From your description, it sounds like you are not reusing cells properly.

Put up some code and we'll have more to work with. You might have to show us your UITableView subclass .m file.

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