cellのdetailTextLabelを表示

2020/09/26確認

f:id:fedora9:20200926161807p:plain

QiitaのAPIでタイトルを表示

 

Table View CellのStyleをSubtitleに変更します。

f:id:fedora9:20200926161355p:plain
detailTextLabelに値をセット

  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)

    cell.textLabel!.text = articles[indexPath.row]["title"]! as? String

    cell.detailTextLabel!.text = articles[indexPath.row]["created_at"]! as? String

    return cell

  }

 

実行すると表示します。

f:id:fedora9:20200926161807p:plain

 

Swift – UITableViewの基礎を学ぼう (セルのスタイルの種類について) | WEB ARCH LABO

 

SwiftのTableViewCellを使ってTableViewを自由にカスタマイズ - Qiita

 

【Swift】Cell上のUIImageViewにAPIから取得した画像(URL)を表示させたこと - Qiita