Hen*_*bat 2 uitableview ios swift swift3
这是连接到我的表视图的所有功能。为什么我无法删除行?
我也做在viewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
self.myTableView.dataSource = self
self.myTableView.delegate = self
self.myTableView.reloadData()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.subtitle, reuseIdentifier: "incTV")
cell.textLabel?.text = "X"
cell.detailTextLabel?.text = "Y"
return cell
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
myTableView.deleteRows(at: [indexPath], with: .fade)
arr.remove(at: (indexPath as NSIndexPath).row)
self.myTableView.reloadData()
}
}
override func viewWillAppear(_ animated: Bool) {
myTableView.reloadData()
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2539 次 |
| 最近记录: |