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];
}