Swift 5.0 扩展

2022-08-29  本文已影响0人  Mr_滑

TableView 代理的常用形式

extension HomeViewController : UITableViewDataSource,UITableViewDelegate {
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 3
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let hcell = tableView.dequeueReusableCell(withIdentifier: "HomeCell", for: indexPath)
        hcell.selectionStyle = .none
        return hcell
        
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 300.0
    }
}

上一篇 下一篇

猜你喜欢

热点阅读