美文网首页
Swift 5.0 扩展

Swift 5.0 扩展

作者: Mr_滑 | 来源:发表于2022-08-29 17:20 被阅读0次

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
    }
}

相关文章

网友评论

      本文标题:Swift 5.0 扩展

      本文链接:https://www.haomeiwen.com/subject/gpcknrtx.html