5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Swift3 - UITableViewでセル追加

Last updated at Posted at 2017-03-16

セルの配列

下記のような配列の値がセルに反映されていたとします


var myItems = ["TEST1", "TEST2", "TEST3", "TEST3"]

配列に文字列を追加してUITableViewをリロードする

僕の場合はUIボタンのアクションの中で下記の処理を実行しましたが、どんな感じでも構いません。要は、配列に値を追加してUITableViewをリロードするだけです


// myItemsに追加.
myItems += ["TEST4"]
// TableViewを再読み込み.
MainTableView.reloadData()

参考

swiftUITableViewを編集モードにして、追加、削除、並べ替えをする

Swiftで配列に要素を一つだけ追加する

Inserting and Deleting Rows and Sections

5
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?