Wednesday, October 28, 2026
HomeiOS Developmentios - Develop/Collapse UITableView all the time will get the unsuitable top

ios – Develop/Collapse UITableView all the time will get the unsuitable top

[ad_1]

As this video, (you possibly can obtain supply code from right here, I’ve tried my greatest to take away all of the pointless code)

I have to manually scroll by way of tableview to make it reset to the appropriate top of every cell and if I develop and unexpand a number of cells, it’ll present the unsuitable top once more.

I am making an attempt to make use of “systemLayoutSizeFittingSize” as a substitute of “heightForRowAt”. (CustomCell.swift)

override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize {

    setNeedsLayout()
    layoutIfNeeded()
    
    let defaultHeight: CGFloat = 90
    return CGSize(width: 0, top: !isExpanded ? defaultHeight : tableView.contentSize.top + defaultHeight)
}

I wish to use autolayout as a substitute of giving the precise top for tableview. what do I do unsuitable?

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments