HomeiOS Developmentios - Expandable Collapse TableView repair row to prime

ios – Expandable Collapse TableView repair row to prime


I’ve expandable-collapse tableView. I can repair row to prime when i open it however the issue is when i shut the row that opened on the highest, it’s returning to earlier location. I wish to maintain that row on prime even it’s closed.

When i open it fixing the highest
When i open it fixing the top

I wish to do like that after i shut it at prime
I want to do like that after i close it at top

and that is my perform giving error: Terminating app as a result of uncaught exception ‘NSRangeException’, cause: ‘Tried to scroll the desk view to an out-of-bounds row

 @objc non-public func hideSection(sender: UIButton) {
        let part = sender.tag
        let index = IndexPath(row: 0, part: part)
        
        func indexPathsForSection() -> [IndexPath] {
            var indexPaths = [IndexPath]()
            for row in 0..<self.tableViewData[section].rely {
                indexPaths.append(IndexPath(row: row, part: part))
            }
            return indexPaths
        }
        
        tableViewContentOffset = tableView.contentOffset
        
        if self.hiddenSections.incorporates(part) {
            self.hiddenSections.take away(part)
            self.tableView.insertRows(at: indexPathsForSection(), with: .fade)
            
            if tableView.numberOfRows(inSection: part) > 0 {
                tableView.scrollToRow(at: index, at: .prime, animated: true)
            }
            
        } else {
            self.hiddenSections.insert(part)
            self.tableView.deleteRows(at: indexPathsForSection(), with: .fade)
            
            tableView.scrollToRow(at: index, at: .prime, animated: true)
            
        }
    }

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments