簡體   English   中英

如何通過單擊按鈕快速在iOS的UITableview中插入行?

[英]How to insert row in UITableview in iOS in swift by clicking Button?

如何通過iOS中的按鈕單擊事件迅速在UITableview插入新行? 我已盡力做到這一點,但我的所有代碼均無法正常運行,因此請幫助解決該問題。

在按鈕事件中,只需將數據添加到用於填充tableView的數組中,然后創建tableView.reloadData()

所以你的初始數組

var data = ["One", "Two", "Three"]

您的按鈕事件:

@IBAction func addData(sender: AnyObject) {
    data.append("Four")
    tableView.reloadData()
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM