Ios UITableView indexPath.row未增加
我正在将数据加载到UITableView中。第一次加载在第一次加载的前10个单元中正确发生Ios UITableView indexPath.row未增加,ios,swift,uitableview,Ios,Swift,Uitableview,我正在将数据加载到UITableView中。第一次加载在第一次加载的前10个单元中正确发生 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {} 行正确递增,并将数据从数据源加载到正确的单元格中。然后,当到达表的底部时,我实现了加载更多。现在调用了func tableView,但它停留在indexPath.row=9。我在中实现了一个检查器 fun
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {}
行正确递增,并将数据从数据源加载到正确的单元格中。然后,当到达表的底部时,我实现了加载更多。现在调用了func tableView,但它停留在indexPath.row=9。我在中实现了一个检查器
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
而且似乎已经添加了适当数量的行
编辑:我对我的第二个uitableview(在这个场景中有两个)有问题checker是一个print语句,它被调用并返回正确的uitableview,这发生在tableView停留在相同的值之前
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if tableView == self.table {
return users2.count
}
else {
print("married barry", tableFeedCount)
return tableFeedCount
}
}
请尝试以下操作:
声明布尔值
let boolNotMoreData : Bool = true
将新数据附加到数据源中
let arrResponse: [Any]? = (responseObject["news"] as? [Any])
if arrResponse?.count == 0{
boolNotMoreData = false;
}
for dictResponse in arrResponse as! [[String: Any]] {
self.arrDataSource.append(NewsClass(responseDict: dictResponse))
}
self.tblViewNews?.reloadData()
现在获取新数据
private func tableView(_ tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.row == arrNews.count - 1 {
if boolNotMoreData {
currentPage += 1
getYourData()
}
}
}
这项工作很成功
@IBOutlet weak var Submitted: UITableView!
@IBOutlet weak var ViewAssigenment: UITableView!
var Arrayone:[String] = []
var ArrayTwo:[String] = []
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
var count:Int?
if tableView == self.ViewAssigenment
{
count = Arrayone.count
}
else if tableView == self.Submitted
{
count = ArrayTwo.count
}
return count!
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
if tableView == self.ViewAssigenment
{
let cell = tableView.dequeueReusableCell(withIdentifier: "ViewCell") as!
ViewAssigenmentTableViewCell
let obj =Arrayone[indexPath.row]
cell.lblTitle.text = obj.AssTitle
return cell
}
else
{
let cell1 = tableView.dequeueReusableCell(withIdentifier: "Submittcell") as! SubmittedAssigenmentTableViewCell
let obj2 = ArrayTwo[indexPath.row]
cell1.lbltitle.text = obj2.AssTitle
return cell1
}
}
你的“棋盘格”代码是什么样子的?