gpt4 book ai didi

ios - 自定义结构以添加参数

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

我需要一点帮助,我正在处理 tableViewController

enter image description here

就像您在图片中看到的那样,我必须向所有单元格添加这些参数:

名称(标签)、图像、类型(标签)、坐标( map )

问题是有了这个函数

class CourseClass: UITableViewController, CLLocationManagerDelegate, MKMapViewDelegate {


@IBOutlet weak var map: MKMapView!



var place = ["Caffè Spagar", "Duks", "Posta station", "Barnum", "Elephant Club", "Cinema", "Space", "Andromeda", "Rodolf", "Devil Chair"]
var rows = 0


override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

return rows
}



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

let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! MyTableViewCell

cell.myImage.image = UIImage(named: (place[indexPath.row] + ".png"))
cell.myLabel.text = place[indexPath.row]

return (cell)
}

我只能获取名称和图像,我知道我必须为所有参数创建一个自定义结构,但我对此有点困惑,任何人都可以做一个代码示例来说明我该怎么做吗?

最佳答案

您应该继承 UITableViewCell,在 Interface Builder 的 tableViewController 中创建一个原型(prototype)单元格,将原型(prototype)单元格的类型设置为自定义 UITableViewCell 类,在原型(prototype)单元格中创建所有 UI 元素,然后将它们链接到您的自定义类。

关于ios - 自定义结构以添加参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44049015/

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