ios - uitableview 中的 uicollection 视图始终显示 0 array.lenth 并且从不加载数据
问题描述
我在我的项目中遇到了一个问题,基本上我想在 uitableview 中使用 uicollectionview 但它总是显示 0 个数组 .count in numberOfItemsInSection of collectionview 这里是 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 的数组,而
解决方案
您从 tableview 传递到experience_array_skill数组的数据始终为零,因此您得到的计数为 0。检查您将数据传递到您的experience_array_skill数组的代码。
推荐阅读
- python - Python - 记录字符串以前的内容
- php - 用于 php 文件的 Nginx try_files
- java - 是否可以在 Spring 中使用枚举实现策略模式
- python - 如何将 Pandas 数据拆分为对象中的 2 位小数
- gnuplot - 没有点的 Gnuplot 等高线图
- java - 根据不同的请求读取具有多个值的 XML 正文元素
- python - tf.nn.conv2d 在 numpy 或 scipy 中(具有 4-d 权重)?
- wordpress - 从干净的 wp 安装到子目录的 Wordpress 重定向问题
- python - WebDriver 是否可以通过调用包含测试跟踪器的 JavaScript 文件的 mouseclick 事件单击元素?
- javascript - 未在 Laravel 5.7 应用程序中加载 vue 文件