使用 NSFetchedResultsController 的 UITableView 空白板岩

发布于 2025-01-02 10:30:39 字数 297 浏览 3 评论 0原文

UITableView 创建空白板岩视图的最佳方法是什么?当 NSFetchedResultsController 没有对象时该视图可见,否则隐藏?

如果我向 UITableView 添加子视图,我需要将其定位以与可能改变大小的 tableHeaderView 对齐。 而且我不确定如何使用 UITableViewCell 作为空白板而不破坏 NSFetchedResultsController 逻辑。

What's the best approach for creating a blank slate view for a UITableView that's visible when the NSFetchedResultsController has no objects, and hidden otherwise?

If I add a subview to the UITableView, I need to position it to align with the tableHeaderView that may change size.
And I'm not sure how to use a UITableViewCell as a blank slate without breaking the NSFetchedResultsController logic.

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

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

发布评论

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

评论(1

抱猫软卧 2025-01-09 10:30:39

您可以使用以下几个选项:

  1. 如果基类是 UIViewController,请在表视图后面添加空消息子视图,并将 hidden 设置为 YES 在表格上

  2. 如果您正在使用UITableViewController,您可以将tableHeaderView设置为空消息视图,确保其高度与表格高度匹配,然后将scrollEnabled设置为< code>NO on the table

  3. 无论哪种情况,您都可以向 UITableView 添加子视图并使用 UIScrollViewDelegate< /code> 方法(主要是 scrollViewDidScroll:)在滚动期间保持视图静止。

There are a few options you can use:

  1. If the base class is a UIViewController, add your empty message subview behind the table view and set hidden to YES on the table

  2. If you are using UITableViewController, you can set the tableHeaderView to your empty message view, ensure its height matches the height of the table, and then set scrollEnabled to NO on the table

  3. For either case, you can add a subview to the UITableView and use the UIScrollViewDelegate methods (mainly scrollViewDidScroll:) to keep the view stationary during scrolling.

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