【发布时间】:2020-06-03 11:43:15
【问题描述】:
如果选择的答案是No,我正在尝试从我的第一个分段控件中获取答案,然后自动选择第二个(以及更多)分段控件的答案。
所以Question1分段控制(是,否,N/A),如果选择No,则对Question2(和Q3,Q4等)分段控制作出答复N/A。
我可以让它单独在Question1上工作,即按No但在Question1上更改为N/A,但我希望它离开Question1为No,然后将Question2等更改为N/A.
我尝试将sender 更改为Question2,但这不起作用。
@IBOutlet weak var Queston2: UISegmentedControl! //Will need to add same for Q3 etc
@IBAction func Question1(_ sender: UISegmentedControl) {
if sender.selectedSegmentIndex == 0 {
//Do stuff
}
else if sender.selectedSegmentIndex == 1 {
sender.selectedSegmentIndex = 2 // Change button to 'N/A', works for this question, but i want it to change Question2, not Question1.
@IBAction func Question2(_ sender: UISegmentedControl) { // generally repeats as Question1 above.
我找到了一些类似的答案,但它们似乎比我认为需要的要复杂得多。
【问题讨论】:
-
所以 - 你有 n 个
UISegmentedControl对象,所有对象都带有“是 - 否 - 不适用”,当在其中任何一个上选择“否”时,所有其他都应该设置为“N/A”吗?但是,如果选择是或不适用,是否要执行其他操作?
标签: ios swift uisegmentedcontrol