【发布时间】:2021-06-27 02:52:48
【问题描述】:
我想制作两个具有不同标签内容的不同 ViewController。 所以我做了这个:
//the buttons
@IBOutlet weak var label: UILabel!
@IBOutlet weak var labeltwo: UILabel!
//Content for the first ViewController
@IBAction func randomword(_ sender: Any) {
let yourDrink = ["Cola", "Fanta", "Water", "Sprite"]
label.text = yourDrink.randomElement()
}
//Content for the second ViewController
@IBAction func randomWordtwo(_ sender: Any) {
let yourFood = ["Pizza", "Appel", "Chees", "Hot Dogs"]
labeltwo.text = yourFood.randomElement()
}
我的 firstViewController 是从我的第一个数组中看到的一切都很好。 但在我的 secondViewController 上,我看到了相同的数组,但我想看到函数“randomWordTwo”(第二个数组)
我有不同的 VC 类、标签和按钮。希望您能帮助我,感谢您的宝贵时间
【问题讨论】:
标签: ios arrays swift iphone class