Augustyniak / RATreeView

Library providing easy-to-use interface for displaying tree structures on iOS and tvOS.
MIT License
2.49k stars 465 forks source link

Expand only on pressing accessory view #189

Closed eshwartm closed 8 years ago

eshwartm commented 8 years ago

Great library. Is there a way to expand only on pressing accessory view on the cell?

eshwartm commented 8 years ago

Well I guess I'll have to use delegate from table view cell class.

av089 commented 7 years ago

@eshwartm how did you solve this? I also want to use + & - buttons for expand/collapse. I want to use didselect for selection

Thank you,

eshwartm commented 7 years ago

@av089

  1. Make a UITableViewCell subclass for your cell which will have +/- accessory view.
  2. Make a protocol having a function expandCollapseCell.
  3. Set the delegate to the main Tree View class (let's call it TreeViewController).
  4. When the arrow/+/- button is pressed, toggle expand/collapse state in the cell.
  5. Call the protocol's function delegate.expandCollapseCell. It will reach the main TreeViewController.
  6. In that delegate function implementation, use the library's in-built expandRowForItem or collapseRowForItem.