gpt4 book ai didi

ios - 为什么我的标题和图像在我点击我的项目时一直在变化?

转载 作者:搜寻专家 更新时间:2023-11-01 06:52:19 26 4
gpt4 key购买 nike

每次我单击我的按钮时,都会显示一个带有导航栏的新 Controller 。但不幸的是,图像和标题改变了它们的顺序并 self 复制。

订单应该是坚定的。

最佳答案

使用您的表、图标和 Controller 名称作为属性创建一个结构并将该结构存储在一个数组中

struct Action {
let label: String
let control: String
let icon: String
}

let actions = [Action(label: "Pläne", control: "PlansViewController2", icon: "plancorrection"),
Action(label: "Dokumentationen", control: "DocumentationListViewCtrl", icon: "list"), ...]

然后从同一个数组中获取所有需要的值

cell.titelLabel.text = actions[row].label
cell.imageView.image = UIImage(named: actions[row].icon)
cell.imageView.tintColor = UIColor.darkGray

获取 View Controller 的正确标识符

if let action = actions.first(where: {$0.label == pnc}) {
let newController = storyBoard.instantiateViewController(withIdentifier: action.control)
} else {
//some error handling here
}

关于ios - 为什么我的标题和图像在我点击我的项目时一直在变化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56354442/

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