Xcode tableview中的多节数组
首先,我想说,我有一个类似的帖子,像这样,但它是如何消失的,所以如果它再次出现,它是不打算双重职位 我创建了一个包含3个部分的uitableview,它由3个不同的数组填充Xcode tableview中的多节数组,xcode,uitableview,sections,Xcode,Uitableview,Sections,首先,我想说,我有一个类似的帖子,像这样,但它是如何消失的,所以如果它再次出现,它是不打算双重职位 我创建了一个包含3个部分的uitableview,它由3个不同的数组填充 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //删除了这里的一堆代码,使其更短 switch (indexPath.section) { case 0
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//删除了这里的一堆代码,使其更短
switch (indexPath.section) {
case 0:
cell.textLabel.text=[DogArray objectAtIndex:indexPath.row];
break;
case 1:
cell.textLabel.text=[BirdArray objectAtIndex:indexPath.row];
break;
case 2:
cell.textLabel.text=[FishArray objectAtIndex:indexPath.row];
break;
default:
break;
}
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
return cell;
}
这三个部分中的每一部分都从各自的数组中获取自己的值
唯一的问题是。在我使用一个数组之前,我会这样分配
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (checInt==0)
{
ThridView *summary=[[ThridView alloc]init];
summary.detailViewController = detailViewController;
self.detailViewController.receivedRainObject = [MainArray objectAtIndex:indexPath.row];//Pay attention to this line
这将通过斗牛犬、鸽子或箭鱼来总结每个人是谁。行…不幸的是,我不能再这样做了,因为我使用了三种不同的数组。我想用一个开关,但即使我从鱼群中选择箭鱼。
NSLOG([DogArray objectAtIndex:indexath.row])向我展示了pitbull
和
NSLOG([BirdArray objectAtIndex:indexath.row])向我展示了dove
所以我不能说这两个是空的
我也很想知道一种方法,即使我选择的每一种动物来自不同的阵列,我仍然可以传递它们,谢谢,在我看来,这应该是你将文本放入单元格时使用的相同逻辑。也就是说,索引路径的部分选择数组,行选择偏移量。将数组传递到-(UITableViewCell*)tableView:(UITableView*)tableView CellForRowIndexPath:(NSIndexPath*)indexPath{}方法中的tableView中。我已经在其中传递了所有3个数组,那么,程序中有什么不起作用了。是的,谢谢,我只是使用了和填充文本相同的大小写