【发布时间】:2020-06-20 09:25:21
【问题描述】:
我在我的项目中遇到了一个问题,基本上我想在 uitableview 中使用 uicollectionview,但它总是显示 0 个数组。collectionview 的 numberOfItemsInSection 中的计数这里是 tableview 单元格内的集合视图的代码
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section:
Int) -> Int {
print(experience_array_skill.count)// always show 0
return experience_array_skill.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath:
IndexPath) -> UICollectionViewCell {
let cell = collects.dequeueReusableCell(withReuseIdentifier: "shorlist_exp_cell",
for: indexPath as IndexPath) as! shorlist_exp_cell
cell.btn1.text = self.experience_array_skill[indexPath.row].experience_in
cell.layer.cornerRadius = 15.0
cell.clipsToBounds = true
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath:
IndexPath) {
}
我的 JSON
{
"message": "candidate job listing",
"status": true,
"data": [
{
"id": 1,
"company_name_shown_job": "xyz company",
"job_title": "Android Developer",
"job_description": null,
"experience_tags": [
{
"id": 2,
"employer_job_post_id": 1,
"experience_in": "Android"
},
{
"id": 3,
"employer_job_post_id": 1,
"experience_in": "Php"
}
]
},
{
"id": 2,
"company_name_shown_job": "Abc company",
"job_title": "Web Developer",
"job_description": "<p>Lorem ipsum dolor sit amet,laborum.</p>",
"experience_tags": [
{
"id": 4,
"employer_job_post_id": 2,
"experience_in": "Swift"
},
{
"id": 5,
"employer_job_post_id": 2,
"experience_in": "Java"
}
]
}
]
}
在上面的 JSON 数据中是我的 uitableview 的数组,而
【问题讨论】:
标签: ios swift xcode uitableview collectionview