A minimal project to reproduce a UISegmentedControl tap position bug in Xcode 26.
When tapping an unselected UISegmentedControl that has dynamically set segments, the tap position is incorrectly calculated. For example, tapping the rightmost segment (index 3) results in the leftmost segment (index 0) being selected instead.
2026-01-22.13.49.20.mov
- Xcode: 26.1.1, 26.2 (confirmed)
- iOS: 18.5, 26.2
- Device: Simulator and physical devices
All of the following conditions must be met:
- Build with Xcode 26.x
UIDesignRequiresCompatibilityis set toYESin Info.plist- UISegmentedControl is laid out using Auto Layout
- Segments are dynamically set (e.g., using
insertSegment(withTitle:at:animated:)after initialization)
- Clone this repository
- Open
SampleSelectSegmentedControl.xcodeprojin Xcode 26.x - Build and run on a simulator or device
- Observe two
UISegmentedControlinstances:- Top: Standard UISegmentedControl with static segments ("Item 1", "Item 2", "Item 3")
- Bottom: CustomSegmentedControl with dynamically set segments ("Item A", "Item B", "Item C", "Item D")
- Tap on the rightmost segment of the bottom (custom) segmented control
The rightmost segment ("Item D", index 3) should be selected.
The leftmost segment ("Item A", index 0) is selected instead.
class CustomSegmentedControl: UISegmentedControl {
func setSegments(titles: [String]) {
removeAllSegments()
titles.forEach { title in
insertSegment(
withTitle: title,
at: numberOfSegments,
animated: false
)
}
}
}class ViewController: UIViewController {
@IBOutlet weak var topSegmentedControl: UISegmentedControl!
@IBOutlet weak var bottomSegmentedControl: CustomSegmentedControl!
override func viewDidLoad() {
super.viewDidLoad()
topSegmentedControl.selectedSegmentIndex = UISegmentedControl.noSegment
bottomSegmentedControl.setSegments(
titles: ["Item A", "Item B", "Item C", "Item D"]
)
bottomSegmentedControl.selectedSegmentIndex = UISegmentedControl.noSegment
}
}<key>UIDesignRequiresCompatibility</key>
<true/>Currently investigating potential workarounds:
- Setting
UIDesignRequiresCompatibilitytoNO(if acceptable for your app) - Using static segments defined in Storyboard instead of dynamic insertion
For more detailed analysis: https://dev.classmethod.jp/articles/xcode26-uisegmentedcontrol-tap-position-bug/
- Apple Developer Forums: (To be added)
- Feedback Assistant: FB21712773