UITableView content height

前端 未结 4 1000
南方客
南方客 2021-01-13 09:02

I have a UITableView that is set to not enable scrolling, and it exists in a UIScrollView. I\'m doing it this way as the design specs call for something that looks like a t

4条回答
  •  终归单人心
    2021-01-13 09:19

    You can run over the sections and use the rectForSection to calculate the total height (this included footer and header as well!). In swift I use the following extension on UITableView

    extension UITableView {
        /**
         Calculates the total height of the tableView that is required if you ware to display all the sections, rows, footers, headers...
         */
        func contentHeight() -> CGFloat {
            var height = CGFloat(0)
            for sectionIndex in 0..

提交回复
热议问题