2014-09-12 2 views
-1

UIPopover에 표시 될 코드에서 UITableView을 만들려고합니다 (전에는이 방법을 사용하지 않았습니다). 디렉토리의 내용 (파일 이름 만)을 나열하고 싶습니다. 이것은 내 코드입니다.프로그래밍 방식으로 UITableViewCell을 구성하는 방법?

- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *cellIdentifier = @"FilenameCell"; 

    UITableViewCell *cell = (UITableViewCell *)[theTableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 
    } 

    cell.textLabel = fileList[0]; 

    return cell; 
} 

분명히 작동하지 않습니다. "읽기 전용 속성에 할당"오류가 발생합니다. 그래서 질문은 :이 경우에 셀의 데이터를 어떻게 설정합니까? 의 결과 쓸모가

+0

캐스트'(나는 귀하의 경우 단지 오타했다 확신)의 text 특성 '을 설정해야합니다. – vikingosegundo

답변

1

당신은 당신의 textLabel ':'dequeueReusableCellWithIdentifier의

cell.textLabel.text = fileList[0]; 
+0

Awww .. 그리고 나도 더 잘 알아! 문제를 고쳤습니다 ... 고마워요. : - { – SpokaneDude

관련 문제