ボタンを押した瞬間の時刻をTableViewで羅列する方法を知りたいです。
現段階では、
func time(){
let formatter = DateFormatter()
formatter.dateFormat = "yyyy/MM/dd HH:mm"
var nowTime = formatter.string(from: NSDate() as Date)//ここまでで、現在時刻の取得
list.append(nowTime) func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return list.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) cell.textLabel!.text = list[indexPath.row] return cell }
ボタンを押したときのアクションとして、上記のtime()関数を呼び出していますが、全く羅列されません。
※TableViewのdelegateとdateSourceはViewControllerに接続済みです。
回答よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー