2013-02-13 2 views
0

plist 데이터를 tableview에 표시하려고합니다.UITableView에서 스크롤 한 후 데이터가 손실되었습니다.

제 문제는 스크롤 한 후 이전에 가져온 데이터를 잃어버린 것입니다. 사실 나는이 일이 일어날 것 같아서 실제로 사용자 정의 셀을 사용하고 있습니다.

소스 코드 및 테이블 위임에 대한 코드는 다음과 같습니다.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
return [tableData count]; 
} 

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

static NSString *kCellID = @"Cell"; 

OffersCustomCell *cell = (OffersCustomCell *)[mytableView dequeueReusableCellWithIdentifier:kCellID]; 
if (cell == nil) 
{ 

    NSString *path = [[NSBundle mainBundle] pathForResource:@"OffersList" ofType:@"plist"]; 

    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"OffersCustomCell" owner:self options:nil]; 

    cell = [nib objectAtIndex:0]; 



    cell.titleLabel.font = [UIFont fontWithName:@"Formata-Regular" size:13.0f]; 
    cell.saveLabel.font = [UIFont fontWithName:@"Formata-Bold" size:14.0f]; 
    cell.nowLabel.font = cell.titleLabel.font; 

    cell.selectionStyle = UITableViewCellSelectionStyleNone; 

} 



NSDictionary *dict = [tableData objectAtIndex:indexPath.row]; 
NSLog(@"%@",dict); 


cell.titleLabel.text = [dict objectForKey:@"title"]; 
cell.nowLabel.text = [dict objectForKey:@"price"]; 
cell.saveLabel.text = [dict objectForKey:@"rondel"]; 
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
return cell; 
} 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
     [mytableView deselectRowAtIndexPath:indexPath animated:YES]; 
} 

답변

0

해결했습니다. :)

UItableview에만 문제가 없습니다.

tableData = [[NSArray arrayWithObjects:[dic objectForKey:@"Response"], nil] retain]; 
0

는 각 셀

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 

    CGFloat height = 0; 
    //calculate height for each cell 

    return height; 
} 

를 사용하여 세포의 높이를 설정하려면이 jQuery과 대리자 메서드의 높이를 설정했다.

0

다른 클래스를 사용하여 데이터를 저장하고 해당 클래스를 사용한 시간을 다시로드하고 데이터를 정확하고 효율적으로 복원 할 수 있습니다.

관련 문제