Augustyniak / RATreeView

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

How to use insertItemsAtIndexes:inParent:withAnimation (bug?) #248

Open limura opened 6 years ago

limura commented 6 years ago

Thank you for a wonderful library. I am working very well in the range that I am using and it is very helpful. Thank you very much.

There is one method which does not work well, so I am glad if you can tell us how to use it. That is how to use "insertItemsAtIndexes: inParent: withAnimation" to add Cell. This function seems to work normally in the usual way. However, under certain conditions I did not do what I expected.

The situation can be reproduced by using the sample "TreeViewController.swift".

The situation which I think as a problem is as follows.

  1. Run TreeViewController.swift with the simulator.
  2. Open the Cell whose "Number of children" value is 1 or more. For example, open "Computers".
  3. Check the "child cells" opened with "2.". Open the Cell whose "Number of children" value is 1 or more. For example, open "Computer 1".

The screen at this point is as follows.

  Computers
    Computer 1
      Notebook 1
      Notebook 2
    Computer 2
    Computer 3
  1. In the state of "3." press the plus button on the right side of "Computers cell" to add a new cell.

In my expectation I thought that it would be as follows.

  Computers
    Computer 1
      Notebook 1
      Notebook 2
    Computer 2
    Computer 3
    Added value

However, it actually became as follows.

  Computers
    Computer 1
      Notebook 1
      Notebook 2
    Computer 2
    Computer 2
    Computer 3

If you added Cell without going through the "3." step (without opening grandchild Cell), "Added value cell" was added as expected.

I am misunderstanding how to use "insertItemsAtIndexes: inParent: withAnimation". I hope you tell me. Thank you for reading.