K
У меня есть table view и есть 10 картинок. Использую стандартную ячейку (image, textLabel, detailTextLabel) Количество ячеек 30. Как сделать так, что бы 11 картинка была такая же, как и 1 и т.д.
p/s
Как правильно понимаю надо брать последнюю цифру числа и выводить картинки согласно номеру
var
pic = ["0","1","2","3","4","5","6","7","8","9"]
var data = [Int]()
override
func viewDidLoad() {
super.viewDidLoad()
for x
in 0...20 {
data.append(x)}
}
func
tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .
default, reuseIdentifier: "cell")
cell.textLabel?.text = "Title \(indexPath.row+1)"
cell.detailTextLabel?.text = "Description \(indexPath.row+1)"
if data[indexPath.row]/10 == 0{
cell.imageView?.image = UIImage(named: pic[indexPath.row])}
return cell
}