Я использую Swift 3. У меня есть UITableView с 7 строк:Добавьте дополнительные строки в TableView
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
}
func tableView(_ tableView:UITableView, numberOfRowsInSection section:Int) -> Int
{
return 7
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
if (IndexPath.row == 6)
{
tableView.beginUpdates()
var index = IndexPath(row: 7, section: 0)
tableView.insertRows(at: [index], with: UITableViewRowAnimation.automatic)
tableView.endUpdates()
}
}
Я хочу, чтобы добавить дополнительные ячейки, когда я прокрутку в последнюю ячейку в таблице. Но я получил эту ошибку:
Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (7) must be equal to the number of rows contained in that section before the update (7), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).
спасибо! оно работает – Kirill