-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
TRSocialCell *cell = (TRSocialCell *)[self.tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"TRSocialCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
__weak TREvent *eventFromParse;
if (!isSearchingEvents){
if ([filteredArray[indexPath.section] count] == 0) {
[cell displayForNoEvents];
cell.selectedBackgroundView = bgCell;
return cell;
} else {
eventFromParse = filteredArray[indexPath.section][indexPath.row];
}
}
else eventFromParse = searched[indexPath.row];
//Cover Image
[eventFromParse.fileForCover getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if (!error) {
eventFromParse.coverPicture = [UIImage imageWithData:data];
cell.coverView.image = [UIImage imageWithData:data];
} else {
[TRAppDelegate displayInternetErrorForView:self.view];
}
}];
cell.titleAutoLabel.text = [NSString stringWithFormat:@"%@",eventFromParse.title];
cell.titleAutoLabel.fadeLength = 0;
cell.titleAutoLabel.pauseInterval = 2.0f;
[animatedLabels addObject:cell.titleAutoLabel];
if (eventFromParse.location != nil) {
cell.addressLabel.text = [NSString stringWithFormat:@"%@",eventFromParse.location.name];
}
[cell.titleAutoLabel setFont:[UIFont fontWithName:@"BigNoodleTitling" size:26]];
[cell.titleAutoLabel setTextColor:[UIColor whiteColor]];
[cell.addressLabel setFont:[UIFont fontWithName:@"BigNoodleTitling" size:18]];
[cell.addressLabel setTextColor:[UIColor whiteColor]];
[cell.dateLabel setFont:[UIFont fontWithName:@"BigNoodleTitling" size:18]];
[cell.dateLabel setTextColor:[UIColor whiteColor]];
cell.dateLabel.text = [NSString stringWithFormat:@"%@ - %@",[TRAppDelegate convertDateToDate:eventFromParse.date],[TRAppDelegate convertDateToTime:eventFromParse.date]];
cell.selectedBackgroundView = bgCell;
}
return cell;
}
메모리가 커지고 있지만 찾을 수없는 문제가 있습니다. 정상적인 경우 if (! 셀) {} 다른 셀로 스크롤 할 때마다 호출됩니다.cellForRowAtIndexPath에서 증가하는 라이브 바이트 수 :
뷰 컨트롤러의 dealloc에서 nil 속성을 설정해야합니까?
이 코드는 어느 정도 유출 될 수 있습니까?
짧은 대답 : 아니요, 처음 몇 개의 셀만 화면에 표시해야하며 기존 셀을 다시 사용해야합니다. 그건 그렇고, 여기에 셀에 데이터를 설정하기위한 올바른 패턴이있다. (옛 방식을 사용하고있다. 새로운 방법은'if (cell == nil) '체크를 사용하지 않는 프로토 타입 셀을 사용한다.) https : //gist.github.com/iwasrobbed/1656ddf1b0ca645bd123 – iwasrobbed