-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SegmentedRow crash due to selectedSegmentIndex == -1 #2238
Comments
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("segs") { $0.value = "Tab1"; $0.options = ["Tab1", "Tab2", "Tab3"] } 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:
I can only recreate this when running as "My Mac (Designed for iPad)" app and only when the app Touch Alternatives is turned off. |
vid.mov |
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.. Screen.Recording.2022-12-13.at.3.57.33.PM.mov |
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. Screen.Recording.2022-12-14.at.11.24.48.AM.mov |
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]
}
The text was updated successfully, but these errors were encountered: