2010-06-07 2 views
0

안녕하세요, 저는 약 200 행의 일부 데이터를 표시하고 있습니다. 데이터는 런타임에 결정되는 여러 섹션으로 표시됩니다. 섹션을 가져올 수 있지만 특정 섹션의 데이터를 올바른 순서로 표시 할 수 없습니다. 사전에 배열 형태로 데이터가 있습니다.Uitableview가 데이터를 보유 할 수 없습니다.

내 코드 :

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
TeraGoAppDelegate *appDel = (TeraGoAppDelegate *)[[UIApplication sharedApplication] delegate]; 
UITableViewCell *cell = nil; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease]; 
    cell.textLabel.text = [(NSMutableDictionary *)[appDel.arrEqp objectAtIndex:countEqpIndex] objectForKey:@"EQP_NAME"]; 
    cell.textLabel.font = [UIFont fontWithName:@"Arial" size:14]; 
    if(![[(NSMutableDictionary *)[appDel.arrEqp objectAtIndex:indexPath.row] objectForKey:@"select"] isEqualToString:@"0"]) 
    { 
     cell.accessoryType = UITableViewCellAccessoryCheckmark; 
    } 
    else 
     cell.accessoryType = UITableViewCellAccessoryNone; 
} 
// Set up the cell... 

return cell; 

}

내가 해달라고 나는이 경우 배열에서 데이터를 얻을 수있는 모든 부분에 0에서 indexPath.row 그러나 그것의 값을 처음 상태를 사용하는 것을 시도하고있다 데이터를 얻기위한 배열의 인덱스. 어떻게 표시해야 할 배열의 인덱스를 얻을 수 있을까요?

업데이트 : 테이블 뷰 배열에 데이터를 추가하는 코드 위에 사용하고 있지만 내가 arrEqps에서 개체를 제거하면, arrCompEqp에서 arrEqps의 객체가도 제거됩니다

[dictComp setObject:arrEqps forKey:CompName]; 
      [arrCompEqp addObject:dictComp]; 
      [arrEqps removeAllObjects]; 

. 데이터가 보존되지 않는 이유는 무엇입니까?

답변

0

우선 테이블을 부드럽게 작동시키고 엄청난 양의 데이터를 표시하려면 셀을 큐에 넣고 큐에서 빼내야합니다. 여기

는 몇 가지 코드에 대한 수정 사항은 다음과 같습니다 인덱스 문제에 대한

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    TeraGoAppDelegate *appDel = (TeraGoAppDelegate *)[[UIApplication sharedApplication] delegate]; 

    static NSString *CellIdentifier = @"CellIdentifier"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier]; 
    if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: CellIdentifier] autorelease]; 
    cell.textLabel.font = [UIFont fontWithName:@"Arial" size:14]; 
    } 

    // Set up the cell... 
    cell.textLabel.text = [(NSMutableDictionary *)[appDel.arrEqp objectAtIndex:countEqpIndex] objectForKey:@"EQP_NAME"]; 
    if(![[(NSMutableDictionary *)[appDel.arrEqp objectAtIndex:indexPath.row] objectForKey:@"select"] isEqualToString:@"0"]) 
    { 
    cell.accessoryType = UITableViewCellAccessoryCheckmark; 
    } 
    else { 
    cell.accessoryType = UITableViewCellAccessoryNone; 
    } 

    return cell; 
} 

- 나는 정확한 문제를 이해하지 않습니다.
일반적으로 각 표 셀은 데이터 소스 배열의 항목을 나타냅니다.

무엇이 countEqpIndex입니까?
indexPath.row도 사용하지 않으시겠습니까?

+0

도움을 내가 희망입니다 섹션은 이미 말했듯이 각 섹션에 대해 별도의 배열을 가져야합니다. 사전 배열 배열 일 수도 있습니다. 상단 배열이 섹션을 나타낼 때 내부 배열 - 셀과 사전은 각 셀에 표시 할 데이터를 보유합니다 (지금처럼). –

+0

답장을 보내 주신 마이클에게 감사합니다. 앞으로 제안 할 사항이 있습니다. 내가 그 일을 끝내면 알려 드리겠습니다. – pankaj

0

당신이 스위치를 사용하여 u는 u는 각 섹션에 대해 배열을 분할해야하므로 다른 배열을 넣어야 할 각각의 경우에, 그래서 사례로 섹션을 선택하면 내 생각이 내 의견 정보] 당신에게

관련 문제