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

后端 未结 13 1040
暗喜
暗喜 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:15

    Swift 4 Elaborating on HorseT's answer, first control drag from your Table View in your storyboard, to your View Controller class and create an outlet called tableView.

    @IBOutlet weak var tableView: UITableView!
    

    Then, your viewDidLoad in your View Controller should look something like this:

        override func viewDidLoad() {
        super.viewDidLoad()
    
        tableView.dataSource = self
        tableView.delegate = self
    
        tableView.tableFooterView = UIView()
    }
    

提交回复
热议问题