-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug] Time Picker is broken in Xamarin.Forms as of iOS 14 Public Beta 6 #11963
Comments
I have found a workaround that might work for some people.
|
To control the behavior of the pickers in iOS 14, set the using System;
using UIKit;
using Xamarin.Forms;
using SetTimer.iOS.Renderers;
[assembly: ExportRenderer(typeof(TimePicker), typeof(TimePickerRenderer))]
namespace SetTimer.iOS.Renderers
{
public class TimePickerRenderer : Xamarin.Forms.Platform.iOS.TimePickerRenderer
{
protected override void OnElementChanged(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs<TimePicker> e)
{
base.OnElementChanged(e);
if (Control != null)
{
UITextField entry = Control;
UIDatePicker picker = (UIDatePicker)entry.InputView;
picker.PreferredDatePickerStyle = UIDatePickerStyle.Wheels;
}
}
}
} This could perhaps be made an effect to be applied to both time and date. I'm sure the team will implement something more elegant, but if anyone feels blocked this should get you going. |
Thank you @davidortinau I would recommend adding an option to the TimePicker and DatePicker controls for the iOS |
There is a similar issue on the DatePicker. I tried a renderer as @davidortinau recommanded with |
@Kingamattack I have made a renderer that uses the old Date Picker as well. I will update this comment around 6 EST today with my renderer. |
@Kingamattack I am not able to test it right now but this should work using System;
using UIKit;
using Xamarin.Forms;
using SetTimer.iOS.Renderers;
[assembly: ExportRenderer(typeof(DatePicker), typeof(DatePickerRenderer))]
namespace SetTimer.iOS.Renderers
{
public class DatePickerRenderer : Xamarin.Forms.Platform.iOS.DatePickerRenderer
{
protected override void OnElementChanged(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs<DatePicker> e)
{
base.OnElementChanged(e);
if (Control != null)
{
UITextField entry = Control;
UIDatePicker picker = (UIDatePicker)entry.InputView;
picker.PreferredDatePickerStyle = UIDatePickerStyle.Wheels;
}
}
}
} This should restore the old Wheels functionality. |
Unfortunately this fix doesn't cause any change in how the time picker is being displayed. Using Xamarin.Forms 5.0.0.1874, with XCode 12.3. |
@abhcr could you try updating to the newest stable release? |
Is there a similar fix available for WebView time and date pickers? I'm seeing the same issue on iOS with 5.0.0sr3 with the following HTML Putting a breakpoint on my custom renderer shows that the renderer is never called from a webview. |
Description
Steps to Reproduce
Expected Behavior
Should Time Wheel when Picker is Selected instead of the old picker style menu with one time to click on.
App should not crash when time wheel is changed
Actual Behavior
Time Picker opens old picker style menu with single incorrect time to click.
Opens new iOS Time Wheel on selection of incorrect time in picker dropdown.
App crashes when time is changed with exception
Basic Information
Screenshots
Reproduction Link
https://github.com/HenryLeC/Xamarin.Forms_iOS_Time_Picker
Workaround
No Workaround Found
The text was updated successfully, but these errors were encountered: