Skip to content
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

Fix crash when attempting to show picker in different mode/style #829

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ios/RNDateTimePickerShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ static YGSize RNDateTimePickerShadowViewMeasure(YGNodeRef node, float width, YGM

__block CGSize size;
dispatch_sync(dispatch_get_main_queue(), ^{
if (@available(iOS 14.0, *)) {
// if this is not reset to the default before setting style it can result in a crash
// use case: picker was first shown with mode that is not UIDatePickerModeCountDownTimer then
// displayed again in different UI with mode UIDatePickerModeCountDownTimer
[shadowPickerView.picker setDatePickerMode:UIDatePickerModeDateAndTime];
[shadowPickerView.picker setPreferredDatePickerStyle:shadowPickerView.displayIOS];
}
[shadowPickerView.picker setDate:shadowPickerView.date];
[shadowPickerView.picker setDatePickerMode:shadowPickerView.mode];
[shadowPickerView.picker setLocale:shadowPickerView.locale];
Expand Down