0
UIButton
アクション機能を使用して、ボタンを押すたびにUITableView
の新しい行が追加されるようにする方法が不思議です。誰もそれを達成する方法を知っていますか?Swift 3のUITableViewを更新するUIButton
UIButton
アクション機能を使用して、ボタンを押すたびにUITableView
の新しい行が追加されるようにする方法が不思議です。誰もそれを達成する方法を知っていますか?Swift 3のUITableViewを更新するUIButton
あなたのUITableViewにIBOutletを設定する必要があります。
UIButtonのIBActionで、tableviewのセルを実装するために使用したデータ構造体に値を追加します。
は、コードIBAction
@IBAction func buttonPressed(_ sender: UIButton)
{
dataStructure.append(someNewValue); // someNewValue is the new Value for the row
table.reloadData()
}
について @IBOutlet weak var table: UITableView!
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell?.textLabel = dataStructure[indexPath.row]
return cell
}
では、テーブルビューの出口
ためreloadData()関数を呼び出します