我正在努力解决以下问题: 我正在从Json下载标题和imageUrl,并使用以下方法将它们设置在我的UITableView自定义单元格中:UITableView单元格UIImageView在选中时随机更改他的框架
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Retrieve cell
NSString *cellIdentifier = @"cell";
UITableViewCell *categoryCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
categoryCell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
categoryCell.textLabel.numberOfLines = 0;
// Get the location to be shown
RecipesList *item = _feedRecipesList[indexPath.row];
// Get references to labels of cell
categoryCell.textLabel.text = item.name;
item.urlImg = [item.urlImg stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
[categoryCell.imageView sd_setImageWithURL:[NSURL URLWithString:item.urlImg]
placeholderImage:[UIImage imageNamed:@"Placeholder.png"]];
return categoryCell;
}
一切工作正常,但当我选择一个单元格(所以它被突出显示)单元格的UIImageView框架更改它的大小没有任何理由。起初我使用的基本单元,我认为这个问题是由导致,所以我试着用定制的小区,在我的.m文件添加以下代码自定义类:
- (void)layoutSubviews {
[super layoutSubviews];
self.imageView.frame = CGRectMake(0,0,55,55);
//Any additional setting that you want to do with image view
[self.imageView setAutoresizingMask:UIViewAutoresizingNone];
}
它调整的UIImageView但再次如果我选择一个单元格的图像帧更改。
有没有人有同样的问题?
而且为了创建延迟加载我使用库SDWebImage,但我不认为问题与此有关。
试过但0运气:(泰帮助无论如何! – Signo