[iOS] Udemy 004:测验应用

于类customTableViewCell中建立单元中各元件的IB出口:

  @IBOutlet弱var cellImage:UIImageView! 
  @IBOutlet弱var topLabel:UILabel! 
  @IBOutlet弱var bottomLabel:UILabel! 
  • 将Table View拖曳至ViewController建立数据源关联
  • 进入ViewController.swift完成功能:cellForRowAt()
    此时尚未设定CoreData,所以先写入固定的文字
  func tableView(_ tableView:UITableView,cellForRowAt indexPath:IndexPath)-> UITableViewCell { 
 让cell = tableView.dequeueReusableCell(withIdentifier:“ cell”,for:indexPath)为!  customTableViewCell 
  cell.topLabel?.text =“总统” 
  cell.bottomLabel?.text =“ 3” 
  cell.cellImage?.image = UIImage(命名为:“ president”) 
 返回单元 
  } 
  • 设定AutoLayout