Reputation: 138
How can i insert new row in UITableview
by click event of button in IOS in swift?
I tried my best to do this but my all code not works so please help to solve it.
Upvotes: 0
Views: 1140
Reputation: 38833
In your button event just add the data to the array that you use to populate your tableView
and then make a tableView.reloadData()
.
So your initial array
var data = ["One", "Two", "Three"]
Your button event:
@IBAction func addData(sender: AnyObject) {
data.append("Four")
tableView.reloadData()
}
Upvotes: 1