在UISegmented控件中禁用段。

问题描述 投票:0回答:1

我有9个分段控件,每个控件都有3个分段,我在所有的控件上都选择了分段3,现在想在每个控件上禁用前2个分段,目前的代码如下,我需要做哪些更改?

    [q2SegControl, q3SegControl, q4SegControl, q5SegControl, q6SegControl, q7SegControl, q8SegControl, q9SegControl, q10SegControl].forEach {
            segmentedControl.setEnabled=false,forSegmentAt:0,1}
ios swift uisegmentedcontrol
1个回答
1
投票

我相信你必须这样使用。

[q2SegControl, q3SegControl, q4SegControl, q5SegControl, q6SegControl, q7SegControl, q8SegControl, q9SegControl, q10SegControl].forEach { segmentedControl in
    segmentedControl.setEnabled(false, forSegmentAt: 0)
    segmentedControl.setEnabled(false, forSegmentAt: 1)
 }
© www.soinside.com 2019 - 2024. All rights reserved.