1
我加載一個包含圖像的表格並上下滾動。一分鐘左右後,我收到「收到內存警告」通知。幾次看到此消息後,該應用程序崩潰。收到的內存警告在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;
}
編輯:
- (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;
}
編輯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
你是否一次加載所有的表? –
我編輯問題。 –