Hi everyone,
I'm encountering a frustrating issue with UIDatePicker in my iOS application and would greatly appreciate any insights or assistance in resolving it.
Description: Upon adding a UIDatePicker to my UIViewController using the drag-and-drop method, the date picker functions correctly, allowing users to select dates without any issues. However, when attempting to change the year by tapping on the month and year view, the application crashes with the following error message:
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
This issue occurs consistently with both the compact and inline styles of UIDatePicker.
Steps to Reproduce:
- Add a UIDatePicker to a UIViewController using the Interface Builder.
- Run the application on a device or simulator.
- Open the UIDatePicker.
- Tap on the month and year view to change the year.
Expected Behavior: The application should allow users to change the year in the UIDatePicker without crashing.
Actual Behavior: The application crashes with the error message mentioned above when attempting to change the year.
Additional Information:
This issue occurs regardless of the date picker's configuration or settings. I've tried various troubleshooting steps, including checking for conflicts with other components and reviewing the view hierarchy, but have been unable to identify the root cause of the problem. If anyone has encountered a similar issue or has any suggestions for resolving this issue, I would be grateful for your assistance.
Attached screenshots of implementation and stack trace.