Ios 如何在具有UITableview行的UICollectionViewCell中显示Json数组数据?
我有一个json数组-Ios 如何在具有UITableview行的UICollectionViewCell中显示Json数组数据?,ios,objective-c,arrays,uitableview,uicollectionview,Ios,Objective C,Arrays,Uitableview,Uicollectionview,我有一个json数组- ( ( ( xyz, abc, efg, hij ), ( suv, xyz, pqr, lmn ),
(
(
(
xyz,
abc,
efg,
hij
),
(
suv,
xyz,
pqr,
lmn
),
(
kmn,
mno,
"uvw",
"xt"
),
(
"pqr",
lm
)
),
)
问题是,我想在集合中的TableView行中显示每个名称,如上面的json数据数组所示。这就是为什么我在UICollectionViewCell中使用Tableview作为
我是这样做的
内部GroupCollectionViewCell-
内置ViewController.h-
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
GroupCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
cell.cellData = [_groupData objectAtIndex:indexPath.row];//here you pass the content for printing the array
cell.delegate = self;
return cell;
}
尝试将数组分组为单个数组的想法,然后将其传递 这是我尝试过的一个示例,得到了如下所示的输出
for (int i=0; i<responceArray.count; i++)
{
mainARRAY=[responceArray objectAtIndex:i];
for (int j=0; j<mainARRAY.count; j++)
{
arrayForEachTable=[mainARRAY objectAtIndex:j];
[_groupData addObject:arrayForEachTable];
}
}
在GroupCollectionViewCell.m中
加
在GroupCollectionViewCell.m中,您可以在其中使用tableView数据源方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"TableCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.textLabel.text = [self.cellData objectAtIndex:indexPath.row];
return cell;
}
内置ViewController.h-
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
GroupCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
cell.cellData = [_groupData objectAtIndex:indexPath.row];//here you pass the content for printing the array
cell.delegate = self;
return cell;
}
尝试将数组分组为单个数组的想法,然后将其传递 这是我尝试过的一个示例,得到了如下所示的输出
for (int i=0; i<responceArray.count; i++)
{
mainARRAY=[responceArray objectAtIndex:i];
for (int j=0; j<mainARRAY.count; j++)
{
arrayForEachTable=[mainARRAY objectAtIndex:j];
[_groupData addObject:arrayForEachTable];
}
}
在GroupCollectionViewCell.m中
加
在GroupCollectionViewCell.m中,您可以在其中使用tableView数据源方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"TableCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.textLabel.text = [self.cellData objectAtIndex:indexPath.row];
return cell;
}
内置ViewController.h-
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
GroupCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
cell.cellData = [_groupData objectAtIndex:indexPath.row];//here you pass the content for printing the array
cell.delegate = self;
return cell;
}
你的意思是说销售、营销、法律、合规性在第一个集合的tableview中ViewCell Excel、Outlook、CMM、专有在下一个单元格的tableview中?你的组数据有正确的值?是的,仅此而已@AbhishekPMmy_groupData的值与我发布的json数组相同@signa什么是_groupData?你的意思是说销售、营销、法律、合规性在第一个集合的tableview中,在下一个单元格的tableview中,Cell Excel、Outlook、CMM、专有?你的_groupData有正确的值?是的,仅此而已@AbhishekPMmy_groupData的值与我发布的json数组相同@SignareA\u groupData的计数是多少?什么是responseArray和arrayForEachTableData?从json响应中处理的第一个数组是responseArray mainArray,它将为存储在arrayForEachTableData中的每个表提供一组数组。您能告诉我如何在方法UITableView*tableView中打印数组\u groupData吗cellForRowAtIndexPath:NSIndexPath*indexPath@AbhishekPMI已经编辑了我的答案,它将按照您的要求打印_组数据。嘿@AbhishekPM在我尝试这个项目时,您能给我发送这个项目吗?在我的情况下,它可以到处打印。请帮忙。请问,什么是responseArray和arrayForEachTableData?从json响应中处理的第一个数组是responseArray mainArray,它将为存储在arrayForEachTableData中的每个表设置一组数组。您能告诉我如何在方法UITableView*tableView CellForRowatineXpath:NSIndexPath中打印数组_groupData吗*indexPath@AbhishekPMI编辑了我的答案,该答案将按照您的要求打印_组数据。嘿@AbhishekPM,您能在我尝试这个项目时发送给我吗?在我的情况下,它将在任何地方打印。请帮忙。请