RATreeView
RATreeView copied to clipboard
Table scrolls when I select an item
I'm using your tree to display reddit threads. When the user taps on a cell (if it has children or not), the table scrolls upward which takes the user away from what they are interested in. This is very repeatable. I've looked through the delegate and datasource methods but I can't seem to find anything about it. Do you have any advice?
Source code is here: https://github.com/zakkhoyt/StopDrinking/blob/today/StopDrinking/ZHRedditThreadViewController.swift
+1. Have the same issue.
@zhlooking I have a question. Are your tree cells using variable height (that is are you using UITableViewAutomaticDimension)? I am indeed and I wonder if this could help narrow down the issue.
I've tried to reproduce this issue with the examples which are supplied but can't get it to happen. The example uses fixed height in the cells. Just a thought.
@zakkhoyt All the cells have the save height. In the latest iOS9.2, the issue may occur when you tap on a cell on the lower half of the screen, even using the examples. But in iOS8, it's correct, so i think it may be related with version differences?
Did you fix this issue yet? I ran into the same problem. Touching a cell near the end of the table makes it scroll up a bit...
@AnotherCoolDude, no fix yet (from me anyhow). I released my app with the bug which is pretty disappointing. The upside is that it only happens sometimes.
My cells are dynamic height and I'm UITableViewAutomaticDimension. I was thinking about trying to calculate the size but that might be quite the chore because of dynamic text size.
Found a workaround:
tl;dr: implement the delegate Methods shouldCollapseRowForItem and shouldExpandRowForItem. Return true if item should be expandable and therefore also collapsible. Otherwise (in case item is not supposed to expand/collapse) return false.
explanation: whenever a cell gets tapped, the treeView-Framework calls the methods expand and collapse regardless wether or not the cell has subcells. If the cell has no subcells, this behaviour leads to our problem. Implementing those two delegate-methods prevents those cells, that have no subcells, from being internally expanded and collapsed.
Have fun
Will try and report back. I think I'm using those methods already
On Jan 5, 2016, at 15:54, AnotherCoolDude [email protected] wrote:
Found a workaround:
tl;dr: implement the delegate Methods shouldCollapseRowForItem and shouldExpandRowForItem. Return true if item should be expandable and therefore also collapsible. Otherwise (in case item is not supposed to expand/collapse) return false.
explanation: whenever a cell gets tapped, the treeView-Framework calls the methods expand and collapse regardless wether or not the cell has subcells. If the cell has no subcells, this behaviour leads to our problem. Implementing those two delegate-methods prevents those cells, that have no subcells, from being internally expanded and collapsed.
Have fun
— Reply to this email directly or view it on GitHub.
@AnotherCoolDude, no go for me. I am already using those methods which always return false. Why? I have a disclose button in each cell. I don't want it to just expand when the user taps anywhere, rather the button only.
I did try your idea, but it doesn't work for my configuration.
This is mega frustrating though. I need to figure this out or roll my own solution.
@AnotherCoolDude and @zhlooking I've integrated this tree view controller into my app with great success. It's a much smaller class and does a great job.
https://github.com/genkernel/TreeView/tree/fsTree-example If you check this out, be sure to look at the view controller in the storyboard. There is an IB object which extends UITableViewDataSource. Wiring it up like the example took me a second as I never use objects directly in IB like this, but I was able to get through it.
Also since RATreeView and TreeVew both use UITableViewCells, it's quite easy to port over.
Good luck!
+1
I have the same issue. I went to see https://github.com/genkernel/TreeView/tree/fsTree-example as @zakkhoyt suggested (thank you so much for having found this gem) 💎 👍
I took me 1 hour to adapt my tree view to this new class : it was not as easy as @zakkhoyt suggested. The logic is different (and somehow interesting, because you see more how it works).
The overall experience is much better, the whole thing seems lighter.