mardi 22 novembre 2016

XCODE Filter Table View Cells with multipe checkboxes

I'm currently developing an app in Xcode. Within this app I want to give the user the possibility to filter the content of Table View Cells (objects) by multiple checkboxes [see picture 1].

Picture 1

Every object thats shown in the Table View has 8 properties which have the value 1, 2 or 3. The checkboxes shown in the filter area are in relationship with these 8 properties.

Like:

  • Checkbox1 = prop1
  • Checkbox2 = prop2
  • Checkbox3 = prop3
  • etc..

Objects arrays:

var objects:[Object] = [
Object(name: "Lorem Ipsum", prop1: "3", prop2: "1", prop3: "1", prop4: "1", prop5: "1", prop6: "1", prop7: "3", prop8: "2"),
Object(name: "Lorem Ipsum", prop1: "1", prop2: "1", prop3: "1", prop4: "3", prop5: "1", prop6: "1", prop7: "3", prop8: "2"),
Object(name: "Lorem Ipsum", prop1: "1", prop2: "2", prop3: "2", prop4: "2", prop5: "2", prop6: "1", prop7: "3", prop8: "2"),
Object(name: "Lorem Ipsum", prop1: "2", prop2: "3", prop3: "3", prop4: "1", prop5: "3", prop6: "1", prop7: "3", prop8: "2"),
Object(name: "Lorem Ipsum", prop1: "1", prop2: "3", prop3: "1", prop4: "2", prop5: "2", prop6: "3", prop7: "2", prop8: "1"),
Object(name: "Lorem Ipsum", prop1: "2", prop2: "3", prop3: "1", prop4: "1", prop5: "1", prop6: "1", prop7: "3", prop8: "2")
]

When all checkboxes are unchecked all the objects will show the same default color (blue).

But when one of the checkboxes is checked, the filter needs to change the color of the objects that have the related property to the selected checkbox, as value 2 or 3. When the value is 2 = change to green color, and when the value is 3 = change to purple color.

So for instance; if checkbox2 is selected, all objects with prop2 as 2 or 3 should have a different color [see picture 2]

Picture 2 (checkbox2 selected)

I did research but couldn't find a way to do it and make it work. If somebody could help, that would be amazing!




Aucun commentaire:

Enregistrer un commentaire