问题
I don't use UITableViews that much but need to in this case. I have a fairly complex Menu object. It has headers and items, like so (imagine a rails acts_as_tree where the menuHeaders array can be arbitrarily deep so there three abstractios: a Menu, a MenuHeaders array which can be nested, and a MenuItems array):
Menu
\menuHeaders is an array
menuHeader - name="Service"
\menuHeaders[]
\menuItems
\menuItem="transmission fix"
\menuItem="replace gaskets"
menuHeader - name="Specials"
\menuHeaders
\menuHeader -name="Tires"
\menuItem - special tire
\menuItem - verySpecial Tire
\menuItems
\menuItem - name="oil change"
\menuItem - name="windows clean"
Output in table:
Service
transmission fix
replace gaskets
Specials
Tires
special tire
verySpecial Tire
oil change
windows clean
I am not sure if I should structure this into a signle UITableView or whether each sub-array should be its own UITableView or how I would iterate over each element? It seems like the cellForRowAtIndexPath can only handle either single arrays or 2D arrays which is not what this is. How would I structure this?
When I render in jQuery I do something like
renderMenHeader(menuHeader)
if(menuHeader.menuItems){
for(mi in menuHeader.menuItems){
renderMenuItem(mi)
}
}
if(menuHeader.menuHeaders){
for(mh in menuHeader.menuHeaders){
renderMenuHeader(mh)
}
}
but not sure how to map this to UITableView abstraction. In all honest, I would rather jsut keep these as separate UIView's but they get up to 300-500 units so I need the ability to handle processing of only visible elements. If there is a workaroudn for handling this in generic UIView's that would also be of interest.
thx
来源:https://stackoverflow.com/questions/25373642/how-to-configure-this-to-be-rendered-in-a-uitableview-or-should-this-be-done-in