gpt4 book ai didi

ios - 重新加载 tableView 部分而不重新加载标题部分 - Swift

转载 作者:IT王子 更新时间:2023-10-29 05:07:44 29 4
gpt4 key购买 nike

我试图重新加载 tableView 部分而不是重新加载整个 tableview,因为我在标题部分有一个文本字段,当我调用 self.tableView.reloadData() 时,我的键盘关闭了。

我已经尝试了下面的代码,但是我得到了这个错误Termating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 5 from section 2 which only contains 4 rows before the update' 那么请问我的问题在哪里?

    let newCount = self.placeArray.count

var newIndexPaths = NSMutableArray(capacity: newCount)

for var i = 0 ; i < newCount ; i++ {
var indexPath = NSIndexPath(forRow: i, inSection: 2)
newIndexPaths.addObject(indexPath)
}

self.tableView.beginUpdates()
self.tableView.reloadRowsAtIndexPaths(newIndexPaths as [AnyObject], withRowAnimation: UITableViewRowAnimation.None)
self.tableView.endUpdates()

最佳答案

您可以改用 UITableViewreloadSections 方法。

tableView.reloadSections(IndexSet(integer: 2), with: .none)

关于ios - 重新加载 tableView 部分而不重新加载标题部分 - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32440885/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com