我有2个字典和字典包含传递numberOfItemsInSection
的数组 1。 self.dicMyClaimsSender
2。 self.dicMyClaimsReceiver
我正在使用分段控制。当我点击片段,然后我重新加载collectionView(我正在使用3集合视图)。
// UISegmentedControl method
@IBAction func segmntAction(sender:UISegmentedControl) {
switch segmnetCtrl.selectedSegmentIndex {
case 0:
self.isSenderSelected = true
self.heightCollection.constant = 130.0
self.heightViewImg.constant = 0.0
self.heightViewVideo.constant = 0.0
self.heightViewFile.constant = 0.0
self.heightBtnAttach.constant = 42.0
self.heightBtnSendFile.constant = 42.0
self.collectionImg.reloadData()
self.collectionFile.reloadData()
self.collectionVideo.reloadData()
break
case 1:
self.isSenderSelected = false
self.heightViewImg.constant = 156.0
self.heightViewVideo.constant = 156.0
self.heightViewFile.constant = 156.0
self.heightCollection.constant = 0.0
self.heightBtnAttach.constant = 0.0
self.heightBtnSendFile.constant = 0.0
self.collectionImg.reloadData()
self.collectionFile.reloadData()
self.collectionVideo.reloadData()
break
default:
break;
}
}
// MARK: - UICollectionView Delegates & Datasources
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if self.isSenderSelected {
if collectionView.tag == 1 {
return self.assets?.count ?? 0
} else if collectionView.tag == 2 {
if self.dicMyClaimsSender.ary_Images.count == 0 {
self.heightViewImg.constant = 0.0
} else {
self.heightViewImg.constant = 156.0
}
return self.dicMyClaimsSender.ary_Images.count
} else if collectionView.tag == 3 {
if self.dicMyClaimsSender.ary_Video.count == 0 {
self.heightViewVideo.constant = 0.0
} else {
self.heightViewVideo.constant = 156.0
}
return self.dicMyClaimsSender.ary_Video.count
} else {
if self.dicMyClaimsSender.ary_Document.count == 0 {
self.heightViewFile.constant = 0.0
} else {
self.heightViewFile.constant = 156.0
}
return self.dicMyClaimsSender.ary_Document.count
}
} else {
if collectionView.tag == 2 {
if self.dicMyClaimsReceiver.ary_Images.count == 0 {
self.heightViewImg.constant = 0.0
} else {
self.heightViewImg.constant = 156.0
}
return self.dicMyClaimsReceiver.ary_Images.count
} else if collectionView.tag == 3 {
if self.dicMyClaimsReceiver.ary_Video.count == 0 {
self.heightViewVideo.constant = 0.0
} else {
self.heightViewVideo.constant = 156.0
}
return self.dicMyClaimsReceiver.ary_Video.count
} else {
if self.dicMyClaimsReceiver.ary_Document.count == 0 {
self.heightViewFile.constant = 0.0
} else {
self.heightViewFile.constant = 156.0
}
return self.dicMyClaimsReceiver.ary_Document.count
}
}
}