gpt4 book ai didi

ios - UITableViewController swift 不同大小的高度与图像

转载 作者:行者123 更新时间:2023-11-28 06:50:33 25 4
gpt4 key购买 nike

我有一个 UITableViewController,它有 2 个单元格,当我在其中放一张照片时,它的大小是一样的。我放在 ViewController.swift 中的编码是

import UIKit

class TableViewController: UITableViewController {
var imageArray = ["1.png","2.png"]

override func viewDidLoad() {
super.viewDidLoad()
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell") as UITableViewCell!

let imageView = cell.viewWithTag(2) as! UIImageView
imageView.image = UIImage(named: imageArray[indexPath.row])

return cell
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return imageArray.count
}
}

screenshot

最佳答案

我不确定你在找什么?如果你想要的是两个高度不同的单元格,你应该尝试覆盖

override func tableView(_ tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
}

在你的delegate .

关于ios - UITableViewController swift 不同大小的高度与图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35042689/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com