func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cellid = "testCellID" //cell的ID var cell = tableView.dequeueReusableCell(withIdentifier: cellid) //对cell赋值 if cell==nil { //判断cell是否为空 cell = UITableViewCell(style: .subtitle, reuseIdentifier: cellid) } cell?.textLabel?.text = "这个是标题~" //标题赋值 cell?.detailTextLabel?.text = "这里是内容了油~" //内容赋值 cell?.imageView?.image = UIImage(named:"Expense_success") //图标赋值 return cell! //返回cell }
返回一个被强制解包的cell.
含义:对cell及cell中的内容进行配置.初始化和复用指定索引位置的UITableViewCell,必须实现.
例如:
标签:indexPath,func,UITableView,tableView,cell,UITableViewCell,赋值 From: https://www.cnblogs.com/lysboke/p/17711947.html