图像限制:
图像设置为比例填充。
我正在使用 SDWebImage 库从服务器加载图像..
当图像加载时,它会覆盖在我的图像正下方的文本区域上。
这是主布局的屏幕截图。未发现约束问题。
这是加载时的图像:
代码如下:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
cell=[tableView dequeueReusableCellWithIdentifier:@"fiscocustomcell"];
int i = (int) indexPath.row;
Newsletter * newstemp = [newsposts objectAtIndex:i];
//get a dispatch queue
;
cell.Title.text=[newstemp title];
cell.Title.numberOfLines=0;
[cell.Title sizeToFit];
cell.Postedby.text=@"Posted by";
cell.Postedby.numberOfLines =0;
[cell.Postedby sizeToFit];
cell.NewsDesc.text=[newstemp desc];
cell.NewsDesc.numberOfLines=0;
[cell.NewsDesc sizeToFit];
NSURL *urlimage = [NSURL URLWithString:[newstemp imagelink]];
[cell.imageView sd_setImageWithURL:urlimage placeholderImage:[UIImage imageNamed:@"service-1.png"]];
[cell setNeedsDisplay];
[cell layoutIfNeeded];
return cell;
}
我从过去 1 周开始就陷入了这个问题,使用了自动解决约束等,也没有任何效果。
应该是这样的:
最佳答案
已解决的问题
问题是 cell.imageView,我正在使用自定义单元格,因此它必须是自定义 uiimage naned,如下所示:
[cell.mycustomimage sd_setImageWithURL:urlimage placeholderImage:[UIImage imageNamed:@"service-1.png"]];
cell.imageView 始终将图像放置在单元格的右侧。
感谢大家,希望这个错误永远不会再发生在任何人身上......
关于ios - 自定义单元格图像未正确对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34107290/