2013-10-23 2 views
0

문자열 배열을 표시하는 tableView가 있습니다. 하지만 나는 (0 또는 1) 값이있는 두 번째 배열이 있습니다. 그것이 0이면 하나의 이미지를 표시하고 텍스트는 검정색으로 표시하지만 1이면 두 번째 이미지와 텍스트를 녹색으로 표시하려고합니다.배열 값으로 클릭시 tableView 셀 레이아웃을 업데이트하십시오. iOS

배열은 구문 분석에서 다운로드합니다. 그것은 작동 중입니다. 내가 아무 일도 발생하지 않는 셀을 클릭 때, 나는 그것을인지 확인해야 내가 코드를 표시 노호 1 또는

if ([NSNumber numberWithInt:0] == [oneOrZeroArray objectAtIndex:indexPath.row]) 
{ 
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 
cell.textLabel.textColor = [UIColor darkTextColor]; 
cell.editingAccessoryType = UITableViewCellAccessoryDetailDisclosureButton; 
cell.imageView.image = [UIImage imageNamed:@"noCheckMark.png"]; 
[oneOrZeroArray replaceObjectAtIndex:indexPath.row withObject:[NSNumber numberWithInt:1]]; 
} 
else if ([NSNumber numberWithInt:1] == [oneOrZeroArray objectAtIndex:indexPath.row]) 
{ 
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 
cell.textLabel.textColor = [UIColor greenColor]; 
cell.editingAccessoryType = UITableViewCellAccessoryDetailDisclosureButton; 
cell.imageView.image = [UIImage imageNamed:@"checkMark.png"]; 
[oneOrZeroArray replaceObjectAtIndex:indexPath.row withObject:[NSNumber numberWithInt:0]]; 
} 

내가 NSLog가 있던 수를 표시하는 셀을 클릭하면 0 때 응용 프로그램이 구문 분석에서 데이터를 다운로드했으나 배열이 클릭시 업데이트되지 않습니다. didSelectRowAtIndexPath의 코드가이 ABIT을 노력과 함께, 그래서

확인 :

EDID (나중에 문제는 내가 셀을 클릭했을 때 새 배열 항목을 업로드하는 것입니다).

how the tableView cell is appearing

당신이 이미지를 잠그면

는 셀은 뭔가를하고있다하지만 난 그것을 다른를 업데이트 한 항목을 클릭하고, 그런 식으로 움직이지한다면 그것은 옳지 않다. 나는 그 그림을 묘사하기 만하면된다. 나는 다른 어떤 세포도 누르지 않는다.

편집 2 : 내 인생에서 실패는 ...

내가 이동하는 경우 : [oneOrZeroArray replaceObjectAtIndex:indexPath.row withObject:[NSNumber numberWithInt:0]]; 그것이 = 작동 didSelectRowAtIndexPath하기).

답변

0

-tableView : didSelectRowAtIndexPath :를 구현 했습니까? 당신은 두 가지 상태 만있는 경우에 당신은 당신의 oneOrZeroArray 배열 부울을 사용할 수 있습니다, 그런데

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
if ([oneOrZeroArray[indexPath.row] intValue] == 0) { 
    oneOrZeroArray[indexPath.row] = @1; 
} else { 
    oneOrZeroArray[indexPath.row] = @0; 
} 
[tableView reloadData]; 

}

+0

: 당신은 뭔가를해야 – acoomans

+0

부울의 문제는 내가 오류가 때를 얻을 수 있다는 것입니다 그것을 파싱하기 위해 업로드하려고 시도하십시오. 그것은 그것이 null이라고합니다. – Nivres

+0

위 코드가 도움이 되었습니까? – acoomans

관련 문제