RATreeView
RATreeView copied to clipboard
When loading data from JSON-API, first couple of rows are hidden under navigation bar...
I have changed the provided example to use with storyboards and loading data from JSON-API using AFNetworking (asynchronous). I use storyboards and navigation controller. When I click a row of treeview I open a detail view controller using segue
- On viewDidLoad I call the API and I set notifications, observers etc.
- When API call is successful a notification handler is triggered that does all the treeview setup (in the provided example this is done in viewDidLoad)
- The first time data are loaded but first 1-2 rows of treeview are covered by navigation bar
- If I select a row, a detail view controller is openning
- Going back to treeview, the first 1-2 rows are not lost anymore! They appear as they should be.
I suspected that this might have to do with wrong timing of calling viewWillAppear. I made several tests on that but without success. Even calling the code inside viewWillAppear directly did not solve the issue. When came back from detail view controller it appears the viewWillAppear of the treeview is called...
When changing my code to not load data from JSON-API but use inline demo data as in the example, the application works fine.
I just encountered with this issue. It has been a while since you opened the issue but let me explain how i solved this in order to help others who might encounter this.
You must not call setuptreeview function when you get answer from the API. Setup operation must be done in viewDidLoad, you just need to change treeView(treeView: RATreeView, numberOfChildrenOfItem item: AnyObject?) function a bit so that it returns 0 when you are waiting your data from the API. When you get your data, set the data and call treeView.reloadData()