Unplanned
Last Updated: 20 Jul 2024 13:54 by yuri
Dinesh
Created on: 05 Mar 2024 09:07
Category: Calendar & Scheduling
Type: Bug Report
3
Calendar: [iOS] NSInternalInconsistencyException is thrown when DisplayDate is set to future date

In the RadCalendar, if we set the DisplayDate to future date (For example, current date is 04-03-2024 and the display date as 08-April-2024), application gets crashed in iOS platform. This issue occurs only in iOS 17 and above versions.

Exception

NSInternalInconsistencyException Reason: UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={0, 0}
3 comments
yuri
Posted on: 20 Jul 2024 13:54

I understood. Full code for workaround:

 public class LocaleCalendarRenderer : CalendarRenderer
 {
     protected override TKExtendedCalendar CreateNativeControl()
     {
         return new CustomTKExtendedCalendar();
     }
 }

 public class CustomTKExtendedCalendar : TKExtendedCalendar
 {
     private bool _initialNavigateToDate = true;

     public override void NavigateToDate(NSDate date, bool animated)
     {
         base.NavigateToDate(date, animated: !_initialNavigateToDate && animated);
         _initialNavigateToDate = false;
     }
 }
yuri
Posted on: 20 Jul 2024 12:50

Thanks, Evan

Can you provide full code with this solution? Don't understand point 2 :(

Evan
Posted on: 08 Jul 2024 18:46

Workaround: create a custom renderer.

  1. Subclass Telerik.XamarinForms.InputRenderer.iOS.CalendarRenderer and export the renderer.
  2. Override CalendarRenderer.CreateNativeControl to return a custom subclass of TKExtendedCalendar.
  3. Override TKExtendedCalendar.NavigateToDate:
// disables animation on initial date navigation (which occurs on initial render)
// the animation takes a screenshot/capture of the UIView using a graphics context with size zero, which is no longer allowed in iOS 17
private bool _initialNavigateToDate = true;
public override void NavigateToDate(NSDate date, bool animated)
{
    base.NavigateToDate(date, animated: !_initialNavigateToDate && animated);
    _initialNavigateToDate = false;
}