【发布时间】:2019-10-03 15:09:40
【问题描述】:
我将两个分段控件堆叠在一起,每个控件都有两个选项,因此搜索字段有一个 2x2 的过滤选项网格。这工作正常,但我刚刚更新到 Xcode 11,当我尝试更新它以响应用户选择时,UISegmentedControl.noSegment 已停止工作。但是,当我在属性观察器中将初始值设置为 .noSegment 时,它会起作用。 isMomentary 设置为假。插座都设置正确。我缺少UISegmentedControl 行为是否有一些更新,或者这是一个错误?
显示新的错误行为here。
之前运行的当前代码,更新后停止运行:
@IBOutlet private weak var segmentedControlOne: UISegmentedControl!
@IBOutlet private weak var segmentedControlTwo: UISegmentedControl! {
didSet {
// Start with no segment selected on this control. This works!
segmentedControlTwo.selectedSegmentIndex = -1
}
}
@IBAction private func oneIndexChanged(_ sender: UISegmentedControl) {
//Turn off selection on second control while first is selected
segmentedControlTwo.selectedSegmentIndex = UISegmentedControl.noSegment
let i = sender.selectedSegmentIndex
if i == 0 {
searchType = .users
} else {
searchType = .contributors
}
}
@IBAction private func twoIndexChanged(_ sender: UISegmentedControl) {
//Turn off selection on first control while second is selected
segmentedControlOne.selectedSegmentIndex = UISegmentedControl.noSegment
let i = sender.selectedSegmentIndex
if i == 0 {
searchType = .articles
} else {
searchType = .categories
}
}
【问题讨论】:
标签: ios swift uisegmentedcontrol ios13 xcode11