Accessory View Challenge


I thought I might do the first challenge using the following strategy.

  1. Put all the labels for all 4 variables (possessionName, dateCreated, serialNumber and valueInDollars) in separate subviews on the cell.
  2. Set the frames for name and serial number to have identical values then do the same for value and date. Name and serial number will obscure value and date. Send the subviews for value and date to the back and the other two subviews to the front.
  3. When a “clicked the accessory button” notification is received from HomepwnerItemCell find the two subviews at the front and switch them with the two at the back.

I haven’t succeeded because I haven’t been able to discover and manipulate the subviews by index.

Is this a feasible approach and any clues as to how to manipulate the subviews?

I don’t know what will happen when I scroll a particular cell off the screen and then back ( I suspect it will come back in the default condition) but I’ll worry about that later.

Since I posted this I found a very helpful article on subView manipulation - … -of-views/


I prefer this approach as well.

You can use the hidden property to toggle which views are displayed.

  1. Layout all 5 subviews (image, name, value, serial, date)
  2. Initially set the serial/date subviews to hidden
  3. When the user clicks the accessory view, toggle the hidden state of the name/value/serial/date subviews.

The view state will need to be maintained somewhere other than in the cell because cells are reused when you scroll in the tableview.