我正在开发一个应用程序,它有UISwitch。我想通过编程将开关设置为开/关。我试过了,但是当setting为false时,开关已经打开了...有什么想法吗?
@IBOutlet var switch: UISwitch!
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
switch = UISwitch()
if setting == true {
switch.setOn(true, animated: false)
} else {
switch.setOn(false, animated: false)
}
} 变量setting不是问题所在。我已经测试过了
发布于 2016-08-31 04:33:30
我修好了!
我刚刚删除了行switch = UISwitch(),现在它对我起作用了。
https://stackoverflow.com/questions/39235915
复制相似问题