如何将 UITableViews 用于多个数据集
我目前正在玩一个基于导航的应用程序。我希望允许用户通过在触摸时选择几个不同的 uitableview 单元格之一来构建搜索查询,将他们引导到一个子 uitableview,在其中我将显示数据供用户选择。
每个单元格将加载相同的子视图,但它将加载不同的数据集。我想知道处理数据转换的适当方法(当用户从子视图中选择单元格时,我如何控制数据应发送回哪个单元格?
我正在考虑将子视图传递到主视图的 Indexpath选定的单元格..然后将其传递回子视图从堆栈中弹出时,以便它知道数据需要在哪里..这是最好的解决方案还是他们的另一种方法?
I am currently playing around with a navigational based app. Where I want to allow the user to construct a search query by selecting one of several different uitableview cells when touched leads them to a sub uitableview where I will display the data for the user to select.
each cell will load the same subview however it will load it with different datasets. I am wanting to know an appropriate way of handling the transition of data (when the user selects the cell from the subveiw how can I control which cell that data should be sent back to?
I am thinking about passing the subview the Indexpath of the mainviews selected cell.. then passing it back to when the subview is poped from the stack so that it knows where the data needs to be.. is that the best solution? or is their another way of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,为主视图所选单元格的索引路径指定子视图的属性。在推送子视图之前,在主视图的 didSelectCell 方法中设置此属性。
将索引路径与数据一起传递回主视图后,您可以使用它
来访问正确的单元格。
Yes, give the subview a property for the indexPath of main view's selected cell. Set this property in the main view's didSelectCell method before pushing the subview.
Once you pass that indexPath back to the main view with you data, you can use
to access the correct cell.