使用 NSFetchedResultsController 的 UITableView 空白板岩
为 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以下几个选项:
如果基类是
UIViewController
,请在表视图后面添加空消息子视图,并将hidden
设置为YES
在表格上如果您正在使用
UITableViewController
,您可以将tableHeaderView
设置为空消息视图,确保其高度与表格高度匹配,然后将scrollEnabled
设置为< code>NO on the table无论哪种情况,您都可以向
UITableView
添加子视图并使用UIScrollViewDelegate< /code> 方法(主要是
scrollViewDidScroll:
)在滚动期间保持视图静止。There are a few options you can use:
If the base class is a
UIViewController
, add your empty message subview behind the table view and sethidden
toYES
on the tableIf you are using
UITableViewController
, you can set thetableHeaderView
to your empty message view, ensure its height matches the height of the table, and then setscrollEnabled
toNO
on the tableFor either case, you can add a subview to the
UITableView
and use theUIScrollViewDelegate
methods (mainlyscrollViewDidScroll:
) to keep the view stationary during scrolling.