You get the following exception in iOS when you open a new calendar and very quickly select a date (as fast as possible). This doesn't seem to happen in Android. To give full disclosure, I'm using a static ObservableCollection to load appointments to the calendar. The collection isn't loaded every time the calendar is displayed because it may have already been updated in the last 30 minutes. However, I can recreate the problem with and without the collection loading.
System.InvalidCastException: Unable to cast object of type 'TelerikUI.TKCalendarMonthPresenter' to type 'UIKit.UIView'
2015-10-23 14:51:37.757 BGNMobileAppiOS[3344:820123] Unhandled managed exception:
Unable to cast object of type 'TelerikUI.TKCalendarMonthPresenter' to type 'UIKit.UIView' (System.InvalidCastException)
at ObjCRuntime.Runtime.GetNSObject[UIView] (IntPtr ptr) [0x00000] in <filename unknown>:0
at UIKit.UIView.get_Superview () [0x00010] in /Users/builder/data/lanes/2077/1d27ac2c/source/maccore/src/build/ios/native/UIKit/UIView.g.cs:3647
at Xamarin.Forms.Platform.iOS.PageRenderer+<ViewAndSuperviewsOfView>d__22.MoveNext () [0x00035] in <filename unknown>:0
at System.Linq.Enumerable.Any[UIView] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
at Xamarin.Forms.Platform.iOS.PageRenderer.OnShouldReceiveTouch (UIKit.UIGestureRecognizer recognizer, UIKit.UITouch touch) [0x0000c] in <filename unknown>:0
at UIKit.UIGestureRecognizer+_UIGestureRecognizerDelegate.ShouldReceiveTouch (UIKit.UIGestureRecognizer recognizer, UIKit.UITouch touch) [0x0000d] in /Users/builder/data/la
8 Answers, 1 is accepted
This issue appears in one of our previous releases. The issue is addressed in the latest official release - Q3 2015 (2015.3.1016). Please, could you confirm that you are using this version? If yes, could you provide us with a sample project where we can reproduce the issue. Thank you in advance.
Looking forward to your reply.
Regards,
Jack
Telerik
We did several tests, however we are not able to reproduce this issue when using our latest release. Please, could you give us more information about the issue:
1. Is the issue appearing on simulator or on device?
2. What is the iOS and Xcode versions that you are using?
3. What is the Xamarin version?
Sending us a sample project or code snippet that we can use to reproduce this issue will help us to locate it faster and to find a proper solution.
Looking forward to your reply.
Regards,
Jack
Telerik
Telerik version: 2015.3.1016
Xamarin Version: 1.5.0.6447
Here's the code. Just put in App.css and run
using System;
using Telerik.XamarinForms.Input;
using Telerik.XamarinForms.Common;
using Xamarin.Forms;
namespace CalendarDemo
{
public class App : Application
{
public static MainPage _MasterDetailPage { get; set; }
public static NavigationPage _NavPage { get; set; }
public App()
{
_NavPage = new NavigationPage();
// The root page of your application
MainPage = new MainPage();
}
}
public class MainPage : MasterDetailPage
{
ContentPage menuPage;
public MainPage()
{
App._MasterDetailPage = this;
menuPage = new ContentPage { Icon = "menu.png", Title = "Menu" };
Master = menuPage;
NavigateToPage((Page)Activator.CreateInstance(typeof(FirstPage)));
}
public async void NavigateToPage(Page targetPage = null)
{
if (targetPage != null)
{
await App._NavPage.PushAsync(targetPage);
Detail = App._NavPage;
IsPresented = false;
}
}
}
public class FirstPage : ContentPage
{
public FirstPage()
{
var layout = new StackLayout();
var button = new Button
{
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
Text = "Press for Calendar",
};
button.Clicked += Button_Clicked;
layout.VerticalOptions = LayoutOptions.CenterAndExpand;
layout.HorizontalOptions = LayoutOptions.CenterAndExpand;
layout.Children.Add(button);
Content = layout;
}
private void Button_Clicked(object sender, EventArgs e)
{
App._MasterDetailPage.NavigateToPage((Page)Activator.CreateInstance(typeof(CalendarPage)));
}
}
public class CalendarPage : ContentPage
{
private static DateTime _DefaultDateTime = new DateTime(2000, 1, 1);
public CalendarPage()
{
RadCalendar radCalendar = new RadCalendar();
radCalendar.SelectedDate = _DefaultDateTime;
radCalendar.SelectionChanged +=
(object sender, ValueChangedEventArgs<object> e) =>
{
DateTime? selectedDate = e.NewValue as DateTime?;
radCalendar.SelectedDate = _DefaultDateTime;
App._MasterDetailPage.NavigateToPage((Page)Activator.CreateInstance(typeof(DateDetailPage), selectedDate));
};
Content = radCalendar;
}
}
public class DateDetailPage : ContentPage
{
public DateDetailPage(DateTime? dateTime)
{
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "Welcome to DateDetailPage!!!"
}
}
};
}
}
}
Thank you for sending those details.
I confirm the issue now. I logged it on our feedback portal and the issue will be addressed in our upcoming release in the beginning of November. You can use this link to track the issue status. I hope the time frame is OK for you. I updated also your Telerik points for bringing our attention to the issue.
Do not hesitate to contact us if you have other questions.
Regards,
Jack
Telerik
When will the new release come out that will have this fix in it? I'm ready to deploy my app and this is the only thing holding it up.
Joe
The upcoming UI for Xamarin release is due in the middle of the next week. You can subscribe to the Release History RSS which will pop with right after the new release is out.
Regards,
Nikolay
Telerik
I am glad to inform you that we have just released the new version of UI for Xamarin where your case is addressed. The new version works with Xamarin.Forms 2.0.0. Release Notes will follow shortly. Feel free to download the bits from your account.
Regards,
Nikolay
Telerik