Problem Statement : I want to dequeueReusableCell "PromotionCellIdentifier"
cells everywhere indexPath.row == 4 * n
but it only run dequeueReusableCell "PromotionCellIdentifier"
one time . I need a solution.
It have only dequeueReusableCell "PromotionCellIdentifier" one time because n == 1 not increment += 1
What I tried :
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let homeSection = Section(rawValue: indexPath.section)!
var n = 1
switch homeSection {
case .Promotion:
let cell = tableView.dequeueReusableCell(withIdentifier: "",
for: indexPath)
return cell
case .Information:
if indexPath.row == 4 * n{
let cell = tableView.dequeueReusableCell(withIdentifier: "PromotionCellIdentifier",
for: indexPath)
n += 1
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "MenuItemCellIdentifier",
for: indexPath) as! MenuTableViewCell
let index = indexPath.row != 0 ? indexPath.row - 1 : 0
let menu = menuItems[index]
let number = menu.like
let stringNumber = numberdecimal(number: number)
cell.configure(imageName: menu.imageName, title: menu.name, detail: menu.details, like: stringNumber,nameLike: menu.likeImage)
return cell
}
}
Required Output : I want to implement in this way
My Output : This is my result 1 & This is my result 2
I need:
adjust row
adjust row
adjust row
adjust row
promotion row
adjust row
adjust row
adjust row
adjust row
promotion row
adjust row
adjust row
adjust row
adjust row