【发布时间】:2020-06-05 04:30:19
【问题描述】:
基本上,我的目标是,如果 VC 上的按钮标题是某个东西,则该按钮会将用户带到某个其他 VC,与按钮标题是否是其他东西不同...... 我没有转场,因为我不能去两个地方?
class ThirdViewController: UIViewController {
@IBOutlet weak var buttonName: UIButton!
var text:String?
override func viewDidLoad() {
super.viewDidLoad()
self.buttonName.setTitle(self.text, for: .normal)
// Do any additional setup after loading the view.
}
@IBAction func buttonPressed(_ sender: UIButton) {
func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if text == "sad" {
_ = segue.destination as! act1ViewController
}
else if text == "yay" {
_ = segue.destination as! act2ViewController
}
}
}
}
【问题讨论】:
标签: swift button uiviewcontroller segue