Issue rendering UIDatePicker on iPhone XS and 11plus only RRS feed

  • Question

  • User392445 posted

    I have a Forms project that needs a combined date & time picker, so off to the custom renderer land I went. Things seemed fine when I was testing on my iPhone 8 Plus test device, but on an iPhone XS or 11 Pro (physical devices, both on 13.3) the picker does not render correctly - all the dates are greyed out, and time is completely invisible. I played with the forms side layout as well as UIDatePicker properties, but nothing had any effect on the rendering issues on newer iOS devices. Unsurprisingly, the simulator for both those devices renders correctly. The entire sample project can be found on GitHub, esenciadev/DatePickerTest (I registered a new account to post this and so cannot post a direct link, apologies)

    Page: <StackLayout Orientation="Vertical" Margin="8,16,8,16"> <Label Text="This is just a test" HorizontalOptions="Center" Margin="8,16,8,16" VerticalOptions="Start" /> <local:MyDatePicker Date="{Binding Date}" Margin="8,16,8,16" DateChangedCommand="{Binding DateChangedCommand}" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"/> </StackLayout>

    Relevant code from the renderer: ``` protected override void OnElementChanged(ElementChangedEventArgs e) { base.OnElementChanged(e);

    if (e.OldElement != null)
        _datePicker.ValueChanged -= DatePickerOnValueChanged;
    if (e.NewElement != null)
        if (Control == null)
            _datePicker = new UIDatePicker(new CGRect(
            _datePicker.Mode = UIDatePickerMode.DateAndTime;
            _datePicker.Date = (NSDate) Element.Date;
            _datePicker.MaximumDate = (NSDate) Element.Date.AddDays(1);
            _datePicker.MinimumDate = (NSDate) Element.Date.Subtract(TimeSpan.FromDays(5));
            _datePicker.MinuteInterval = 1;
        _datePicker.ValueChanged += DatePickerOnValueChanged;

    } ```

    Monday, January 27, 2020 4:39 PM

All replies

  • User369978 posted

    Duplicate of https://forums.xamarin.com/discussion/177100/issue-rendering-uidatepicker-on-iphone-xs-and-11plus-only

    Tuesday, January 28, 2020 2:38 AM