2012-09-28 4 views
-1

샘플 프로젝트에 등록 양식이 있습니다. 등록 양식을 테이블보기로 디자인했습니다. 그것은 8 개의 텍스트 필드로 구성되어 있으며 입력 할 때 데이터를 등록합니다. 그러나보기를 스크롤하면 등록 양식보기 텍스트 필드의 데이터가 사라집니다.데이터가 사라짐

+0

저는 사람들이 코드 나 세부 정보없이 도움을 줄 수 있다고 생각하지 않습니다. 코드에 액세스하지 않고 질문을 읽는다고 상상해보십시오. – bryanmac

+0

적어도 코드를 게시하십시오. 스크롤 할 때 필드의 텍스트 int가 사라져 다시 스크롤 할 이유가 없습니다. 이것은 매우 이상합니다. – nycynik

답변

2

tableView:cellForRowAtIndexPath: 잘못 처리하고 있습니다. 새 셀을 요청할 때마다 새 셀을 만드는 것처럼 들립니다. 각 행 또는 전체 셀의 텍스트 필드를 저장하고 특정 행이 요청 될 때마다 동일한 필드를 리턴해야합니다.

0
//first allocate the view only cell is empty,and assign values after if (cell == nil){} loop using tag 


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

     static NSString *CellIdentifier [email protected]"Cell"; 
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

      if (cell == nil) 
     { 
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
      lable.frame=your frame; 
      [cell.contentView addSubview :lable]; 
      titleLbl.frame=your frame; 
      [cell.contentView addSubview :titleLbl]; 

       } 
         UILabel *titleLbl = (UILabel *)[cell viewWithTag:101]; 
         UITextField *txtfield = (UITextField *)[cell viewWithTag:102]; 

         titleLbl.text = @""; 

    } 
관련 문제