【问题标题】:Size of a photo in a cell, inside TableViewTableView 内单元格中照片的大小
【发布时间】:2019-11-20 09:46:46
【问题描述】:

我需要把照片的具体尺寸。 在 imageView.image 字段中

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell = tableView.dequeueReusableCell(withIdentifier: "Quiz Cell", for: indexPath)
        let row = indexPath.row
        let quiz = model.quizzes[row]

        cell.textLabel?.text = quiz.question
        cell.detailTextLabel?.text = quiz.author?.username ?? "Anónimo"
        cell.imageView?.image = UIImage(named: "none")

        return cell
    }

【问题讨论】:

  • 上面的代码有什么问题?在 QUIZ 单元格中设置图像的高度和宽度
  • 有什么问题?
  • 您必须在测验单元格中设置它,请提供您的单元格的代码。
  • 代码没有问题。但是我需要设置图像的具体尺寸,我可以在哪里设置这些值?

标签: ios swift uitableview uikit


【解决方案1】:

您需要在单元格本身的Storyboard.xib 中设置特定的imageView 大小。

如果您不使用Storyboard's 或.xib's,也可以通过编程方式进行设置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-28
    • 2021-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多