uiswitch不改变状态ios
Uiswitch does not change the state ios
我的 UISwitch
有问题。当我 select 或 deselect 时,我的开关 state(isHighlighted, selected)
始终为 0。我正在使用 iOS 8.3.
- (IBAction)sliderOnOff:(id)sender {
NSLog(@"%lu", (unsigned long)_sliderOnOff.state);
}
日志:
2015-04-27 22:41:50.617 Project[4011:179116] 0
2015-04-27 22:41:50.762 Project[4011:179116] 0
2015-04-27 22:41:50.972 Project[4011:179116] 0
2015-04-27 22:41:51.088 Project[4011:179116] 0
2015-04-27 22:41:51.226 Project[4011:179116] 0
2015-04-27 22:41:51.343 Project[4011:179116] 0
你能帮帮我吗?
我认为您需要用于 UISwitch 的 on
属性。所以它是 switch.on
,而不是 switch.state
。
您可能需要先将 id
转换为 UISwitch
才能访问 属性。
您需要访问 UISwitch
的 on
属性。
您当前阅读的是超级 class UIControl
的 UIControlState
又名 state
,它会通知您有关选择、突出显示等的信息。
NSLog(@"%lu", (unsigned long)_sliderOnOff.on);
我的 UISwitch
有问题。当我 select 或 deselect 时,我的开关 state(isHighlighted, selected)
始终为 0。我正在使用 iOS 8.3.
- (IBAction)sliderOnOff:(id)sender {
NSLog(@"%lu", (unsigned long)_sliderOnOff.state);
}
日志:
2015-04-27 22:41:50.617 Project[4011:179116] 0
2015-04-27 22:41:50.762 Project[4011:179116] 0
2015-04-27 22:41:50.972 Project[4011:179116] 0
2015-04-27 22:41:51.088 Project[4011:179116] 0
2015-04-27 22:41:51.226 Project[4011:179116] 0
2015-04-27 22:41:51.343 Project[4011:179116] 0
你能帮帮我吗?
我认为您需要用于 UISwitch 的 on
属性。所以它是 switch.on
,而不是 switch.state
。
您可能需要先将 id
转换为 UISwitch
才能访问 属性。
您需要访问 UISwitch
的 on
属性。
您当前阅读的是超级 class UIControl
的 UIControlState
又名 state
,它会通知您有关选择、突出显示等的信息。
NSLog(@"%lu", (unsigned long)_sliderOnOff.on);