I have Two collectionviews. 1)newCollectionview 2) oldCollectionview
if i add any image in newCollectionview then
- initially i need to show newCollectionview with newArray images
if i am coming from isEdit
-
if isEdit == true
if oldArray.isEpty == false -----> oldCollectionview with oldArrayif i add only new images where oldArray images are not present
if newArray.isEpty == false -----> newCollectionview with newArrayif i add new images where oldArray images are present
if oldArray.isEpty == false && newArray.isEpty == false -----> oldCollectionview and newCollectionview
for that condition i have tried like below: with this code i am not able to show initially newArray with newCollectionview and even if isEdit true then also if there are images in oldArray then only i am able to show newArray with newCollectionview... if i add more then oldArray images to newCollectionview then those images are not showing in newCollectionview but those are added in JSON but not showing in newCollectionview... why?
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if isEdit{
if oldArray.isEmpty == false{
if collectionView == oldCollectionview{
return oldArray.count
}
}
if newArray.isEmpty == false{
if collectionView == newCollectionView{
return self.newArray.count
}
}
if oldArray.isEmpty == false && newArray.isEmpty == false{
if collectionView == oldCollectionview{
return oldArray.count
}
if collectionView == newCollectionView{
return self.newArray.count
}
}
}
else{
if collectionView == newCollectionView{
return self.newArray.count
}
}
return newArray.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if isEdit{
if oldArray.isEmpty == false{
if collectionView == oldCollectionview{
let cell = oldCollectionview.dequeueReusableCell(withReuseIdentifier: "FilesCollectionCell", for: indexPath) as? FilesCollectionCell
let img = "\(CommonUrl.bidsAttachment)\( self.oldArray[indexPath.item].image ?? "")"
cell?.imgView.getImage(withUrl: img, placeHolder: #imageLiteral(resourceName: "home"), imgContentMode: .scaleAspectFill)
}
}
if newArray.isEmpty == false{
if collectionView == newCollectionView{
let cell = newCollectionView.dequeueReusableCell(withReuseIdentifier: "FilesCollectionCell", for: indexPath) as? FilesCollectionCell
cell?.imgView.image = self.newArray[indexPath.item]
return cell!
}
}
if oldArray.isEmpty == false && newArray.isEmpty == false{
if collectionView == oldCollectionview{
let cell = oldCollectionview.dequeueReusableCell(withReuseIdentifier: "FilesCollectionCell", for: indexPath) as? FilesCollectionCell
let img = "\(CommonUrl.bidsAttachment)\( self.oldArray[indexPath.item].image ?? "")"
cell?.imgView.getImage(withUrl: img, placeHolder: #imageLiteral(resourceName: "home"), imgContentMode: .scaleAspectFill)
return cell!
}
if collectionView == newCollectionView{
let cell = newCollectionView.dequeueReusableCell(withReuseIdentifier: "FilesCollectionCell", for: indexPath) as? FilesCollectionCell
cell?.imgView.image = self.newArray[indexPath.item]
return cell!
}
}
}
else{
if collectionView == newCollectionView{
let cell = newCollectionView.dequeueReusableCell(withReuseIdentifier: "FilesCollectionCell", for: indexPath) as? FilesCollectionCell
cell?.imgView.image = self.newArray[indexPath.item]
return cell!
}
}
return UICollectionViewCell()
}
}
please do help with condition check
Aucun commentaire:
Enregistrer un commentaire