-(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 (!cell) {} keep beign 调用是否正常?
我必须在视图控制器的 dealloc 中将属性设置为 nil 吗?
这段代码可能泄漏了什么?