2012-06-25 7 views
0

나는 3 셀이있는 tableView 있습니다.TableView 프로토콜 바깥 쪽 UITableViewCell.detailTextLabel 변경

tableView로드 된 후 그 셀의 .detailTextLabel을 변경하고 싶습니다.

어떻게 할 수 있습니까?

있는 UITableViewCell firstCell * = [있는 tableView cellForRowAtIndexPath : 0]

난이 아드;

firstCell.detailTextLabel.text = @ "ABC";

[tableView reloadData];

그러나 이것은 아무 것도하지 않습니다. 무슨 문제 야? reloadData를 호출하는

UITableViewCell *firstCell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; 

firstCell.detailTextLabel.text = @"ABC"; 

필요 :

답변

1

대신

UITableViewCell *firstCell = [tableView cellForRowAtIndexPath:0]; 

사용

UITableViewCell *firstCell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; 
+0

이 작동하지 않습니다. 아무것도 변경되지 않았습니다. – theShay

0

이 시도하지 않는다.

+0

이것은 작동하지 않습니다. 아무것도 변경되지 않았습니다. – theShay

+0

[tableView reloadData] 주석 처리 했습니까? tableview 대리자 메서드가 호출되기 전에 변경하면 cellForRowAtIndexPath가 값을 무시하므로 detailTextLabel을 변경하는 위치입니다. –

+0

tableView 대리자 메서드가 호출 된 후에이를 호출합니다. – theShay

0

당신이 말할 때

[있는 tableView reloadData];

그 때 당신 : -

(있는 UITableViewCell *)있는 tableView : (jQuery과 *)있는 tableView cellForRowAtIndexPath : (NSIndexPath *) indexPath;

당신이 당신의 연속 3 세포가 있고이 다시 당신이 당신의 배열을 통해 제공해야 원본 텍스트와 firstCell.detailTextLabel.text을 무시하므로

방법은

그래서 ... 세 번 호출됩니다 만약 당신이 배열을 사용한다면, 그 배열에서 필요한 인덱스를 위해 객체를 변경해야합니다.

단지이를 구현 :

[배열 replaceObjectAtIndex : 0 withObject : "변경"@]

[tableViewCategory reloadData];

희망이 있으므로 ...

+0

이것은 배열이 아닙니다 .... – theShay

관련 문제