Open mikeymike9000 opened 1 year ago
Have you been able to reproduce this issue? How does it happen that the selectedSegmentedIndex is -1? Does that happen when no segment is selected?
Sorry I don't have more details yet and haven't figured out how to reproduce. It happens quite often so I'll create a video and screenshots next time I run into it. It occurs seemingly randomly when changing from one segment to another after setting them up like this:
<<< SegmentedRow
It occurs on devices as well as simulators and "My Mac (Designed for iPad)", and has been occurring through MacOS 12/13 and Xcode 13/14.
ok I figured out how to recreate:
1) run my iOS app as "My Mac (Designed for iPad)" 2) click on the window of another open app to make that app active 3) click back in the window of my app directly on a Eureka segment
I can only recreate this when running as "My Mac (Designed for iPad)" app and only when the app Touch Alternatives is turned off.
I believed this had also occurred in simulators and on devices for the past year or more but I could be mistaken.
here's an example where it shows the issue including the hack where I select index 0 when avoiding the crash..
NOTE: the issue also occurs when my app is created as Ad Hoc or installed via TestFlight.
Instead of setting to 0, did you try just returning without doing anything?
Returning without doing anything deselects the Segment's tab visually but doesn't actually hide the tab's content (see attached video). I will continue manually setting the index to 0 in case having it 'unset' while its content is accessible could cause other issues. My current hack/workaround is fine for me, I just wanted to let you know.
I'm also using Swift Package Manager, so what I've done is make a local copy of SegmentedRow.swift in my Xcode project, and renamed the file and class to be SegmentedRowCustom.
When selecting different Section Segments sometimes my app crashes due to segmentedControl.selectedSegmentIndex (within class SegmentedCell) returning a "-1" instead of legitimate value that is >=0
Existing Eureka code: @objc (segmentedValueDidChange) func valueChanged() { row.value = (row as! OptionsRow).options?[segmentedControl.selectedSegmentIndex]
}
Hack I'm using to avoid the crash: @objc (segmentedValueDidChange) func valueChanged() { if segmentedControl.selectedSegmentIndex == -1 { segmentedControl.selectedSegmentIndex = 0 } row.value = (row as! OptionsRow).options?[segmentedControl.selectedSegmentIndex]
}