How to remove extra empty cells in TableViewController, iOS - Swift

后端 未结 13 1038
暗喜
暗喜 2020-12-22 16:12

Hi I have a TableViewController with two static cells, however when displayed, it shows the two static cells, and then all the other empty cells for the tablevi

13条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-22 16:37

    I tried the tableview.tableFooterView = UIView() and it did not work for me. I am using a custom TableViewViewCell, perhaps that is why.

    I did find a hack tho. In my func numberOfRowsInSection

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return yourArrayClass.count - 1
    }
    

    And that makes my extra blank custom UITableViewCell not display anymore. Of course its the extra blank one. I will test it some more by adding more Cells. For reference, I am using Swift 3, Firebase, a custom cell class, inside the cellForRowAt function.

提交回复
热议问题