Загружаю таблицу с изображениями и прокручиваем вверх и вниз. Через минуту или около того я получаю уведомление «Предупреждение о получении памяти». После просмотра этого сообщения несколько раз приложение сбой.Предупреждение о принимаемой памяти В UITableView
Я загружаю положением прокрутки 5 изображений каждый раз, когда пользователь прокручивает нижнюю часть таблицы.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"aCell";
PostTable_Cell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
CGFloat cellHeight = (screenWidth/16) * 10 + self.view.frame.size.height * 0.09;
cell = [[PostTable_Cell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier withParentWidth:self.view.frame.size.width withCellHeight:cellHeight withParent:self withPostArray:[postsArray objectAtIndex:indexPath.row] withCurrentIndexPostArray:(int)indexPath.row];
[cell setUserInteractionEnabled:YES];
cell.selectionStyle = UITableViewCellStyleDefault;
tableView.separatorColor = [UIColor blackColor];
return cell;
}
Edit:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"aCell";
PostTable_Cell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
CGFloat cellHeight = (screenWidth/16) * 10 + self.view.frame.size.height * 0.09;
if (cell == nil)
{
cell = [[PostTable_Cell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier withParentWidth:self.view.frame.size.width withCellHeight:cellHeight withParent:self withPostArray:[postsArray objectAtIndex:indexPath.row] withCurrentIndexPostArray:(int)indexPath.row];
[cell setUserInteractionEnabled:YES];
cell.selectionStyle = UITableViewCellStyleDefault;
tableView.separatorColor = [UIColor blackColor];
}
else
{
[cell reloadCellContetWithParent:self withPostArray:[postsArray objectAtIndex:indexPath.row] withCurrentIndexPostArray:(int)indexPath.row];
}
return cell;
}
Edit 3:
@implementation PostTable_Cell
- (void)awakeFromNib
{
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
-(void)dealloc
{
#ifdef DEBUG
NSLog(@"%@ destoyed",NSStringFromClass([self class]));
#endif
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier withParentWidth:(CGFloat)parentWidth withCellHeight:(CGFloat)celltHeight withParent:(id)parent withPostArray:(id)postArray withCurrentIndexPostArray:(int)IndexNumber
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
mainDalegate = (Main*)parent;
self.backgroundColor = [UIColor clearColor];
Post *curPost = (Post*)postArray;
postId = [curPost getPostId];
postText = [curPost getPostText];
postImageUrl = [curPost getImageUrl];
commentsCount = [curPost getCommentsCount];
likesCount = [curPost getLikesCount];
likeByMe = [curPost getLikeByMe];
facebookId = [curPost getCreatorFacebookId];
publisherName =[curPost getCreatorName];
currentIndexPostArray = IndexNumber;
[GeneralMethods setNew_width:parentWidth ToView:self];
[GeneralMethods setNew_height:celltHeight ToView:self];
[self cellBuilderForPost];
}
return self;
}
Очевидно, что ваши изображения не будут выпущены. Вам нужно показать код, чтобы кто-нибудь мог вам помочь. В частности, ваш «cellForRowAtIndexPath» будет полезен – ullstrm
вы загружаете всю свою таблицу сразу? –
Я редактирую вопрос. –