UITableViewController 动态深入分析
在包含 10 个单元格的表格视图中,我们是否需要创建 10 个单独的 UITableViewController 来处理通过单击这 10 个单元格中的每一个单元格加载的不同视图?
这似乎不是很有效 - 特别是在需要显示大量数据(以及表格/菜单)的情况下。
如何编写一个动态 UITableViewController,它可以动态接受任何数据集(如数组)并显示其内容 - 并以可回收的方式进行,以便可以为每个单元格一次又一次地重新创建它点击?
In a table-view that contains say 10 cells, is it the case that we need to create 10 separate UITableViewControllers to handle the different views loaded by clicking on each of those 10 cells?
That doesn't seem very efficient - especially in situations where large amounts of data (and thus tables/menu) need to be displayed.
How can you write a dynamic UITableViewController, that can accept any data-set (like an Array) on the fly and display its contents - and do it in a recyclable manner, so that it can be recreated again and again for each cell that is clicked?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我主要在我正在构建的应用程序中工作 - 我唯一不完全理解该方法的是“CurrentLevel”的递增如何工作,因为自从控制器调用以来,变量似乎会不断重置本身。
无论如何,这个概念是,每次有人单击一个单元格时,都会调用 UITableView 控制器的一个新实例,并生成一个新级别并将其添加到“堆栈”中,并且导航控制器能够跟踪堆栈中的内容并允许您浏览回之前加载的视图。
I have it mostly working in an app I'm building - the only thing I don't fully understand about the method is how the incrementing of the "CurrentLevel" works since it seems like the variable would just keep getting reset since the controller calls itself.
Anyhow, the concept is that every time someone clicks a cell, a new instance of the UITableView controller is called and a new level is generated and added to "the stack", and a navigation controller is able to track what is in the stack and allow you to browse back to the previously loaded views.