I have a table view with 2 levels, the first with 4 rows and a disclosure accessory on each, and the second with a list of values. I want to be able to select a row, which then loads the corresponding list. You can then select values which will result in a checkmark in the cell .
When you return to the first level with the 4 objects, I want the selected values to show up as strings underneath the object title string within the same cell, like a detail string.
I have been able to populate the table view correctly, and add and remove checkmarks to each 2nd level cell when selected.
The first problem: when you scroll down, the checkmarks rearrange themselves at random. Second: I can't find any documentation to use a table view as a picker.
I have used arrays to populate the tableviewcells. Is it possible to assign each object within that array a boolean value for being checked or not?
Should I use a plist and for each object, i'll have its title and boolean checked value.
Any assistance you could give me is greatly appreciated.
i m not sure if i understood exactly what u asked, but may be u can use section headers instead of table cells. u can put buttons to section headers and when a button is clicked, selected section's cells can be populated with appropriate data. (for example i used it for football competitions, section headers had names of countries, and all sections have 0 cells, and when a country is clicked, clicked section's number of cells set and cells are loaded with the selected country's competitions.)
if u think this can solve ur problem, i can explain more detailed.
Well, I really wanted to stick to the basic populated UITableView if possible. I can select a Cell, which will then checkmark the cell. You can select it a second time, and it will uncheckmark.
The problem is, there are 4 sections with 6 or so rows each. When you check a row at the top, scroll down, and then back up, the checkmark is located on a different row. I know this is due to reusing cells. That's fine, but I need a way and example of how to save which cells are selected and checkmarked and possibly assign it to the String in each row (cell).
Then, I want to use the string in each checkmark Cell in another view. I thought this would have been easy to execute. After scouring the internet for ideas, i'm left with dead ends.
You just need to store the checkmarked state somewhere. Several ways to do that.
One way:
You can use one array of NSNumber's (which a little bit of math) or two, it's up to you. The only trick is that since you can't set an NSNumber's value, when someone checks a table cell, you'll have to replace the array entry with a new NSNumber object.
Another way:
Instead of storing a string for each cell, store a struct containing a string and a bool.