Привет, ребята. Я хочу показать только 100 ячеек из моих (10k +) записей.Я пытаюсь сделать это с возвратом 100, но это дает мне ошибку - индекс выходит за пределы диапазона, и это нормальное поведение для этого, но я не знаю, как сделать это хорошо, как я хочу ..: (
Проблема в том, что я хочу показать только 100 ячеек, но я хочу найти всех диктов ... вот мой код:
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
let count = self.items.count
return 100
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let item: Price = items[indexPath.row]
tableView.selectRow(at: IndexPath(row: -1, section: 0), animated: false, scrollPosition: UITableViewScrollPosition.none)
showLargePhoto(price: item)
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CatalystItem", for: indexPath) as! CatalystTableViewCell
let item: Price = items[indexPath.row]
let appSettings: AppSettings = AppSettings()
cell.lpLabel.text = String(item.no)
cell.catCermaicValueLabel.text = "\(item.ceramWeight) kg"
if appSettings.getHideMetalWeights() == false {
cell.catPtValueLabel.text = item.viewPt ?? ""
cell.catPdValueLabel.text = item.viewPd ?? ""
cell.catRhValueLabel.text = item.viewRh ?? ""
}
else {
cell.catPtValueLabel.text = ""
cell.catPdValueLabel.text = ""
cell.catRhValueLabel.text = ""
}
cell.textCategoryLabel?.text = item.group ?? ""
if FileUtilities.fileExists(nridasnString+".jpg") {
let image: UIImage? = UIImage(named: tmbLocalPath.path)
let scaledImage: UIImage? = image?.scaleToWidth(width: 100)
if cell.imageView != nil {
cell.imageView!.removeFromSuperview()
let iv: UIImageView = UIImageView(frame: CGRect(x: 20, y: 40, width: 100, height: 75))
iv.image = scaledImage
iv.contentMode = .scaleAspectFit
cell.addSubview(iv)
}
}
return cell
}
, и я не знаю, как это сделать ... убитьмне, пожалуйста, но я покончил с этим ..