TableViewのSubtitleにおいて取得した日付をセルごとにつけたいのですが、このままだと全て同じ時刻になってしまいます。理由はsDateに日付が入っていて、それを表示しているからです。
しかし解決策がわからず頓挫しております。解決策を教えていただきたいです。
swift
1func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 2 let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) 3 //日付のフォーマットを指定する 4 let format = DateFormatter() 5 format.dateFormat = DateFormatter.dateFormat(fromTemplate: "yMdkHm", options: 0, locale: Locale(identifier: "ja_JP")) 6 //日付をStringに変換する 7 let sDate = format.string(from: date) 8 9 cell.textLabel!.text = resultArray[indexPath.row] 10 cell.detailTextLabel!.text = sDate 11 12 return cell 13 }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/03 03:03 編集
2019/01/03 23:32 編集