【问题标题】:Image in presenterImageView not displaying properlypresenterImageView 中的图像未正确显示
【发布时间】:2017-12-05 22:47:28
【问题描述】:

我修改了 PresenterCard 示例代码以使用我的 firebase 数据库而不是图形库。但是,它不能正确显示图像。本质上,图像不会缩放以适合视图。我有

presenterImageView.contentMode = .scaleAspectFill

我该如何解决这个问题?

编辑:

我使用以下代码下载图片

storageRef.getData(maxSize: 1 * 1024 * 1024) { (data, error) -> Void in
    let pic = UIImage(data: data!)
    if let image = pic {
        self.presenterImageView.frame.size.height = image.height
        Motion.async { [weak self, image = image] in
            self?.presenterImageView.image = image
        }
    }
}

card.frame.origin.x = 0
card.frame.origin.y = 0
card.frame.size.width = bounds.width

frame.size.height = card.bounds.height
presenterImageView.frame.size.height = 300

图片已加载,但无法缩放。

【问题讨论】:

  • 你能分享更多你的设置吗?
  • @CosmicMind 更新了我的更多设置,如果您需要我添加更多内容,请告诉我。
  • @CosmicMind 你有机会看看吗?

标签: cosmicmind


【解决方案1】:

解决了我自己的问题。不得不删除该行:

self.presenterImageView.frame.size.height = image.height

现在工作正常!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-25
    • 1970-01-01
    • 1970-01-01
    • 2021-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多