首先,我想說我有類似這樣的帖子,但有些它是如何消失的,所以如果它再次出現,它不打算加倍張貼。tableview中的多段數組
我創建了3段一個UITableView並正在從3個不同的陣列
- (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
這將在鬥牛,鴿子或箭魚傳遞到總結的基礎上每誰是.row ....不幸的是,我不能再這樣下去了,因爲我使用三個不同的數組。我正在考慮使用開關,但即使當我從魚羣中選擇劍魚時也是如此。 ([DogArray objectAtIndex:indexPath.row])顯示我pitbull 和 NSLOG([BirdArray objectAtIndex:indexPath.row])顯示我鴿子 所以我不能說當這兩個爲空。
會愛得知道一種方法,我仍然可以通過在我選擇的動物是每個即使他們來自不同的陣列,感謝
傳遞數組到的tableView在 - (UITableViewCell中*)的tableView:(UITableView的*)的tableView的cellForRowAtIndexPath:(NSIndexPath *)indexPath {}方法 – 2012-08-06 12:32:28
林已經通過了所有3個數組中有 – 2012-08-06 12:55:18
那麼,究竟是不是在你的程序中工作。 – 2012-08-06 13:53:09