Возможно ли вынести за пределы метода cellForRowAt ячейку в которой хранятся аутлеты?
Код ячейки такой:
сlass DetailTableViewCell2: UITableViewCell {
@IBOutlet weak var currentPageNumber: UILabel!
}
Основной код:
сlass DetailViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UITableViewDelegate, UITableViewDataSource, UIScrollViewDelegate {
@IBOutlet weak var tableView: UITableView!
var Images: Hall?
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
tableView.estimatedRowHeight = 560
tableView.rowHeight = UITableViewAutomaticDimension
}
---
// MARK: - TableView
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell2 = tableView.dequeueReusableCell(withIdentifier: "cell2", for: indexPath) as! DetailTableViewCell2
cell2.currentPageNumber.text = "1/\(hallImages?.Images.count ?? 0)"
return cell2
}
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let pageNumber = round(scrollView.contentOffset.x / scrollView.frame.size.width)
print("page number is \(pageNumber)/\(Images!.Images.count)")
}
Собственно мне надо перенсти cell2.currentPageNumber.text = “1/(hallImages?.ImagesHalls.count ?? 0)” в scrollViewDidEndDecelerating или наоборот сделать pageNumber в cell, не знаю как лучше и честно даже нету понимания как надо делать, поэтому пишу такой возможно глупый вопрос. Кто знает как сделать помогите…