gpt4 book ai didi

ios - 等效于 UISwtich 中的 UISegmentedControl selectedSegmentIndex - Objective C

转载 作者:行者123 更新时间:2023-11-29 01:11:50 26 4
gpt4 key购买 nike

我正在尝试将 UISegmentedControl 转换为 UISwitch。我成功检查了开关的状态。

然后我看到了这行代码:

self.mobile3GSegment.selectedSegmentIndex = [mConfigurationService getBoolWithKey:NETWORK_USE_3G];

我试图猜测 UISwitch 是如何做到的。所以……

self.mobile3GSwitch.state = [mConfigurationService getBoolWithKey:NETWORK_USE_3G];

然后我收到此错误:

Property 'selectedSegmentIndex' not found on object of type UISwitch

我知道 UISwitch 不是一个段,并且返回 YES 或 NO。错误不是这里的重点。我想要了解的是如何转换代码行以使其适用于 UISwitch。

我现在几乎迷失了。执行此操作的正确方法是什么?

最佳答案

你必须使用一个简单的函数setOn (假设您返回 bool 的方法是正确的)。

[_mobile3GSwitch setOn:[mConfigurationService getBoolWithKey:NETWORK_USE_3G] animated:NO]; 

关于ios - 等效于 UISwtich 中的 UISegmentedControl selectedSegmentIndex - Objective C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35648865/

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