带有未知单元格的动态部分 UITableView
嘿, 我基本上试图从 SQlite 数据库检索数据并从中填充 tableView。
sql-data-retrieval 方法创建两个数组。 “数据数组”和“SectionArray”。
DataArray 填充有数据 NSObject。
到目前为止,我可以创建适当的节标题。
问题是,
-1 我该怎么做才能确保正确的对象进入其适当的部分而不是在任何其他部分下(他们似乎正在这样做)。每个部分中的计数(行数)也不同。
“NumberOfRowsAtIndexPath”和cellForRowAtIndexPath方法中的代码应该是什么
-2 哪种数据源对象更适合这种类型。我只是填充两个 NSMutableArrays - dataArray(rows) 和SectionArray(Section headers)。
Hey,
I'm basically trying to retrieve data from SQlite db and populate a tableView from it.
The sql-data-retrieval method creates two arrays. "dataArray" and "SectionArray".
DataArray is filled with data NSObjects.
Uptil this point, i can create the appropriate Section headers.
Here is the problem,
-1 What do i do to make sure that the right objects get into their appropriate sections and not under any other sections (which they seem to be doing). Also the Count(number of rows) in each section differs.
What should the code be in "NumberOfRowsAtIndexPath" and cellForRowAtIndexPath methods
-2 What kind of datasource objects are more suited for this type. I'm simply filling up two NSMutableArrays - dataArray(rows) and SectionArray(Section headers).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您应该为您创建的每个表头创建许多
NSArray
。在NumberOfRowsAtIndexPath
中,您将返回所请求部分的数组计数,在cellForRowAtIndexPath
中,您将使用部分索引(如前所述)和行索引来选择数组您将选择该数组的行。I think you should make many
NSArray
one for each table header you have created. InNumberOfRowsAtIndexPath
you will return the count of the array for the requested section, and incellForRowAtIndexPath
you will choose your array using the section index (as before) and with the row index you will select the row of that array.