2014-02-10 1 views
0

문제가 발생했습니다. XML 파일에서 데이터를 가져 왔으며이 정보로 행을 채 웁니다. ... 인덱스 0과 인덱스 1의 행을 동일한 데이터 청크를 참조하도록합니다. 대신 행 0은 XML 파일의 청크 0에서 항목을 읽고 행 1은 XML 파일의 청크 1에서 읽습니다. , 난 그냥 내 행을 더 크게 만들 수 있고 더 큰 행 안에 필요한 모든 것들을 포함 할 수 있지만 이것을 프로그램 적으로 할 수있는 방법이 있습니까?동일한 xml 데이터 청크에서 2 행을 읽습니다.

이미지 : 내 행이 xml 파일 의미에서 읽을 때 일어나는 무슨

빨간 선은 녹색 내가 달성하고자하는 것입니다. 제안?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"LiveIdent"; 

    LiveViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

    LiveMatchObject *item = [_tableDataLiveMatch objectAtIndex:[indexPath row]]; 

    if ([item isKindOfClass:[LiveMatchObject class]]) { 

    cell.cellHomeTeamName.text = item.homeName; 
    cell.cellAwayTeamName.text = item.awayName; 
    cell.cellHomeTeam.image = item.homeTeamLogo; 
    cell.cellAwayTeam.image = item.awayTeamLogo; 
    cell.cellHomeTeamScore.text = item.homeGoals; 
    cell.cellAwayTeamScore.text = item.awayGoals; 
    cell.cellDate.text = item.matchDate; 
    cell.cellMatchStatus.text = item.matchMinute; 

     if ([item.matchMinute isEqual: @"Finished"]) { 
      cell.cellMatchStatus.text = @"Terminado"; 
      cell.cellMatchStatusImage.image =[UIImage imageNamed:@"Finished"]; 
     } 

     else if ([item.matchMinute isEqual: @"Postponed"]){ 
      cell.cellMatchStatus.text = @"Por Iniciar"; 
      cell.cellMatchStatusImage.image =[UIImage imageNamed:@"Waiting"]; 
     } 

     else { 
      cell.cellMatchStatus.text = item.matchMinute; 
      cell.cellMatchStatusImage.image =[UIImage imageNamed:@"Live"]; 
     } 

      } 
     else { 
      } 

    if (indexPath.row % 2) { 
     cell.backgroundColor = [[UIColor alloc]initWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1]; 
     cell.cellDate.hidden = YES; 
     cell.cellMatchStatusImage.hidden = YES; 
     cell.cellMatchStatus.hidden = YES; 


    } else { 
     cell.backgroundColor = [[UIColor alloc]initWithRed:235.0/255.0 green:235.0/255.0 blue:235.0/255.0 alpha:1]; 
     cell.cellHomeTeamName.hidden = YES; 
     cell.cellHomeTeamScore.hidden = YES; 
     cell.cellHomeTeam.hidden = YES; 
     cell.cellAwayTeamName.hidden = YES; 
     cell.cellAwayTeam.hidden = YES; 
     cell.cellAwayTeamScore.hidden = YES; 
     cell.cellScoreDash.hidden = YES; 
     cell.accessoryType = UITableViewCellAccessoryNone; 
     cell.userInteractionEnabled = NO; 
    } 

모달 정의 내에서 원하는 코드를 넣으려고했지만 전혀 문제가 해결되지 않았습니다.

답변

0

그들은 당신에게 말하기 때문에 그들은 xml의 두 개의 분리 된 덩어리를 사용하고 있습니다. 당신은 항상 XML 데이터 오브젝트 당 두 개의 세포가 알고 있다면 당신은 단순히 코드에서이 줄을 조정할 수 있습니다

LiveMatchObject *item = [_tableDataLiveMatch objectAtIndex:[indexPath row]]; 

돌아갑니다

LiveMatchObject *item = [_tableDataLiveMatch objectAtIndex:(int)([indexPath row]/2)]; 

에 0, 0, 1, 1, 2, 3, 3 등 ... 그러면 셀 0과 셀 1은 xml 데이터 0, 2 및 3을 참조하고 xml 데이터 1을 참조합니다.

+0

아름다운 ... 그 쉬운 ... 내 아기 plz, 타이 :) – user3271300

0

필자가 언급 한 '더 큰 행'접근법은 올바른 접근 방법입니다.

사용자 인터페이스를 업데이트하거나 선택한 항목으로 작업 할 때 % 피연산자를 사용하는 것이 쉬운 방법이지만/% 또는 % 2를 (를) 일관되게 유지해야하는 것처럼 보입니다. 컨트롤러 인터페이스 전체에서.

나중에 '수직 행렬'또는 '3 행 행렬'(예를 들어)과 같이 디자인을 변경하려면 '큰 행'을 사용하면 레이아웃을 업데이트하는 반면 % 2 접근법을 사용하면 모든 코드를 변경해야합니다.

관련 문제