Augustyniak / RATreeView

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

Scroll UI issue that has persisted for a while. #250

Open svetlanama opened 6 years ago

svetlanama commented 6 years ago

Hi,

Have a scroll UI issue when I use dynamically calculated heigh cells.

Initial RATreeView control setup

func setupTreeView() {
    treeView = RATreeView(frame: view.bounds)
    treeView.register(UINib(nibName: String(describing: EquipmentListCell.self), bundle: nil), forCellReuseIdentifier: String(describing: EquipmentListCell.self))
    treeView.register(UINib(nibName: String(describing: EquipmentChildCell.self), bundle: nil), forCellReuseIdentifier: String(describing: EquipmentChildCell.self))
    treeView.register(UINib(nibName: String(describing: EquipmentCollectionCellDetail.self), bundle: nil), forCellReuseIdentifier: String(describing: EquipmentCollectionCellDetail.self))
    treeView.register(UINib(nibName: String(describing: EquipmentLevelCell.self), bundle: nil), forCellReuseIdentifier: String(describing: EquipmentLevelCell.self))

    treeView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
    treeView.delegate = self
    treeView.dataSource = self
    treeView.treeFooterView = UIView()
    treeView.estimatedRowHeight = 50

    treeView.backgroundView = loadingView
    view.addSubview(treeView)
}

For example, if I use just this everything is fine

func treeView(_ treeView: RATreeView, heightForRowForItem item: Any) -> CGFloat {
     return 50
}

But, I make different heights for the treeView and under the particular conditions - just hide the cells by setup height = 0. Here, I get a scroll issue

func treeView(_ treeView: RATreeView, heightForRowForItem item: Any) -> CGFloat {
    return stats.total.toInt() == 0 ? 0 : 50
}

Please review this video

Is there some way to fix this? Thanks!

fukemy commented 2 years ago

did u solved this?