Expand tableview and increase scrollview content size by an appropriate difference on clicking a button inside a table cell

后端 未结 2 908
面向向阳花
面向向阳花 2021-01-25 05:35

I have a UITableView which has been added inside a UIScrollView as part of a view controller which adheres to a part of the mockup shown below:-

As you can see

2条回答
  •  忘了有多久
    2021-01-25 06:04

    Try this

    func expandCell(_ sender: UI.Button) {
        if self.parent!.indexOfCellToExpand != self.tag {
            print("EXPANDING...")
            self.parent!.indexOfCellToExpand = self.tag
            self.parent!.businessTable.reloadRows(at: [IndexPath(row: self.tag, section: 0)], with: .fade)
            self.parent!.businessTable.scrollToRow(at: IndexPath(row: self.tag, section: 0), at: .top, animated: true)
        }
        else if self.parent!.indexOfCellToExpand == self.tag {
            print("CONTRACTING...")
            self.parent!.indexOfCellToExpand = -1
            self.parent!.businessTable.reloadRows(at: [IndexPath(row: self.tag, section: 0)], with: .fade)
            self.parent!.businessTable.scrollToRow(at: IndexPath(row: self.tag, section: 0), at: .top, animated: true)
        }
        //        self.toggleBusinessesTable()
        yourTableView.reloadData()
    }
    

提交回复
热议问题