2010-02-24 3 views
0

일부 UITextField, UITextViews 및 UIImageViews를 하위보기로 UITableCell에 추가하고 있습니다. TextFields 또는 TextViews에 텍스트를 입력하고 테이블을 위 또는 아래로 스크롤 할 때 드로잉 문제가 발생합니다. 모든 두 번째 필드의 텍스트는 다음과 같이 다른 분야를 중복 : 하위 뷰iPhone SDK - UITableCell의 UITextField 하위 뷰에서 그리기 문제가 발생합니까?

self.formFields = [[NSArray alloc] initWithObjects: 
[[UITextField alloc] initWithFrame:CGRectMake(18.0, 10.0, 284.0, 22.0)], 
[[UITextView alloc] initWithFrame:CGRectMake(18.0, 8.0, 284.0, 140.0)], 
[[UITextField alloc] initWithFrame:CGRectMake(18.0, 10.0, 284.0, 22.0)], 
[[UITextField alloc] initWithFrame:CGRectMake(18.0, 10.0, 284.0, 22.0)], 
[[UIImageView alloc] initWithFrame:CGRectMake(18.0, 18.0, 284.0, 284.0)],nil]; 

그리고 추가 :

- (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

     ... 
    [cell addSubview:[self.formFields objectAtIndex:indexPath.section]]; 
    return cell; 
} 

alt text http://i49.tinypic.com/2gsl4dh.png

내가 이런 형태의 요소를 만드는거야 이 문제를 해결할 방법이 있습니까?

답변

3

어디서나 하위보기를 제거 하시겠습니까? 그렇지 않으면 셀을 계속 재사용하고 있기 때문에 계속 셀에 추가되고 서로 위에 표시됩니다. 새 하위 뷰를 추가하기 전에 이전 하위 뷰를 제거하거나 (나에게 더 논리적 인) 각 섹션마다 다른 셀 식별자와 셀을 만든 다음 각 셀을 만들 때 적절한 하위 뷰를 만들고 추가하십시오.