iosuitableviewaccessoryview

accessory view. Checkmark


I have a tableview and each cell has a switch as accessory view. I can iterate through all cells to see which ones have switch on. I can easily change the accessory view to be a check mark. I need to implement that tapping each cell toggles between checkmark and none.

Then in touchupinside, iterate through all cells to see which ones are checked and which ones are not checked.

I have implemented to check for Switch state

var indexPaths = table.IndexPathsForVisibleRows; 
foreach (var indexPath in indexPaths) 
{ 
   var cell = table.CellAt (indexPath); 
   var switchView = cell.AccessoryView as UISwitch; 
   if (switchView.On) 
      {
       /*code to handle switch on*/
      } 

}

I dont know how to have similar code to check if accessoryview is Checkmark and if it is set to none


Solution

  • Here's an example that uses MarkupKit's LMTableView class to implement selection management:

    http://gkbrown.org/2015/08/10/using-lmtableview-to-implement-radio-button-like-behavior-in-ios-applications/

    Essentially, you define a particular section of a table view as being either single-select or multi-select, and the LMTableView class manages the selection state for you. You can then query the table view to find out which rows are selected, or you can respond to selection events yourself via table view delegate methods.