I have a custom-subclassed UITableViewCell which will include a few labels, to which I want to add some checkbox functionality. One question label and five options are multi-selectable in that UITableviewCell subclass
Since I’m already in a cell, is it possible to use UITableViewCellAccessoryCheckmark to imitate checkbox functionality? Another option would be to navigate to another tableview using UINavigationController, but I want the user to see the options in the same page.
Also, since I don’t know the number of options beforehand, is it possible to design this custom cell using a XIB and yet still dynamically add some items (for example UISwitch, or UIButtons) at runtime? Or do I have to code it all without using a XIB?
In short, Yes.
UITableViewCellis a subclass (somewhere down the way) of aUIView. That said you can insert aUITableViewin it and create your checkbox allike cells. Think of it as nested tables:Table of questions -> question cell -> table of answers -> answer cell.So what you want to do is to make your custom
UITableViewCellimplementUITableViewDelegateandUITableViewDataSourcethen you want to insert an UITableView in the IB.When you want to show your question cell with 4 answers you would pass a parameter of answers as a
NSArrayto the customUITableViewCell. It then will use it to create inner cells that will behave as answer cells.Hope that helps.