【问题标题】:iOS UIImageView constraint not working in table celliOS UIImageView 约束在表格单元格中不起作用
【发布时间】:2016-03-28 21:12:13
【问题描述】:

我已经实现了一个带有UIImageView 的表格视图单元格。 widthheight 的约束已应用于情节提要中的 UIImageView。但是,当我滚动表格视图时,图像被调整为更大的尺寸(图像原始尺寸)。

这里是演示: (当图像滚动出视口并消失然后重新出现时,图像会调整大小。约束不起作用。)

【问题讨论】:

  • imageview 的contentMode 属性设置为什么?试试UIViewContentModeScaleAspectFit...
  • 图像视图已经在 UIViewContentModeScaleAspectFit 中
  • 您想分享您的项目吗?你确定你使用的是自定义的 imageview 而不是 tableviewcell 的 imageview 属性吗?

标签: ios objective-c iphone uiimageview nslayoutconstraint


【解决方案1】:
  1. 将 contentMode 设置为 UIViewContentModeScaleAspectFit
  2. 将 clipToBounds 设置为 true

【讨论】:

  • 测试过,还是一样。
  • 你设置 translatesautoresizingmaskintoconstraints = false 了吗?
  • 是的,cell.imageView.translatesAutoresizingMaskIntoConstraints 是假的
猜你喜欢
  • 2016-04-04
  • 1970-01-01
  • 2011-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多