ios - 自定义单元格图像未正确对齐

标签 ios objective-c uiimageview tableview

enter image description here

图像限制:

enter image description here

图像设置为比例填充。

我正在使用 SDWebImage 库从服务器加载图像..

当图像加载时,它会覆盖在我的图像正下方的文本区域上。

这是主布局的屏幕截图。未发现约束问题。

这是加载时的图像:

enter image description here

代码如下:

-(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 周开始就陷入了这个问题,使用了自动解决约束等,也没有任何效果。

应该是这样的:

enter image description here

最佳答案

已解决的问题

问题是 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/

相关文章:

javascript - JS : How does event. 涉及属性(property)工作?

ios - UIPopoverPresentationController 不会禁用标题 View 上的点击手势

iphone - 每次从同一 View 加载应用程序

ios - 在不缩放 UIImage 的情况下调整 UIImageView 的大小

ios - 使用自动布局的带有缩放 UIImageView 的 UIScrollView

ios - 如何在 ios 中遍历 Web 服务器中的文件夹层次结构

ios - Alamofire 与 XCode 8 Beta 6 的集成

iphone - 在 iPhone 键盘中添加符号

ios - 如何理解应用了旋转变换的 UIView 的框架?

ios - TabBarController - 第一个 View 偏移 20px