我正在使用集合视图创建电影票证应用。我把卡座安排在collectionView中。如何自定义自定义流程布局?我想在集合视图单元格的特定行中有特定数量的席位
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if collectionView == leftCollectionView {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "leftcellid", for: indexPath) as! LeftSideMovieCollectionViewCell
let selectedseat = leftsideArray[indexPath.row]
if selectedSeatArray.contains(selectedseat) {
cell.leftMovieSeatImageView.image = UIImage.init(named: "seatfulled")
} else {
cell.leftMovieSeatImageView.image = UIImage.init(named: "seatblank")
}
if indexPath.row == 16 || indexPath.row == 17 || indexPath.row == 12 || indexPath.row == 13 {
cell.leftMovieSeatImageView.isHidden = true
} else {
cell.leftMovieSeatImageView.isHidden = false
}
return cell
} else if collectionView == RightCollectionview {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "rightcellid", for: indexPath) as! RightSideMovieCollectionViewCell
let selectedseat = rightsideArray[indexPath.row]
if selectedSeatArray.contains(selectedseat) {
cell.RightMovieseatImageView.image = UIImage.init(named: "seatfulled")
} else {
cell.RightMovieseatImageView.image = UIImage.init(named: "seatblank")
}
if indexPath.row == 18 || indexPath.row == 19 || indexPath.row == 14 || indexPath.row == 15 {
cell.RightMovieseatImageView.isHidden = true
} else {
cell.RightMovieseatImageView.isHidden = false
}
return cell
} else {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "maincellid", for: indexPath) as! MainCollectionViewCell
let selectedseat = vipSeatArray[indexPath.row]
if selectedSeatArray.contains(selectedseat) {
cell.mainSeatImageView.image = UIImage.init(named: "seatfulled")
} else {
cell.mainSeatImageView.image = UIImage.init(named: "seatblank")
}
if indexPath.row == 43 || indexPath.row == 42 || indexPath.row == 34 || indexPath.row == 33 {
cell.mainSeatImageView.isHidden = true
} else {
cell.mainSeatImageView.isHidden = false
}
return cell
}
}
这里我拍摄了三个集合视图。我隐藏了特定的细胞。我不知道如何修改它。可以使用单个集合视图完成吗?任何建议将不胜感激。