I have a problem navigating my iOS application developed using Xamarin.
In any view in my application, when I used the back button at least once and pulled out the view controller, I might have to deal with this System.InvalidCastException exception in my main class:
Unable to cast object of type 'App.iOS.UI.PhotoTaker.PhotoTakerViewController' (Objective-C type: 'WorkZoneSelectorViewController') to type 'App.iOS.UI.WorkZoneSelector.WorkZoneSelectorViewController'. Additional information: Selector: viewDidLoad Method: App.iOS.UI.WorkZoneSelector.WorkZoneSelectorViewController:ViewDidLoad ()
In this example, I was on PhotoTakerViewController and used PopToRootViewController to successfully return to HomeViewController (this can also happen when I use the back button until I return to HomeViewController). Then I tried using segWorkZoneSelector to display the WorkZoneViewController. This is where this error appeared. So for some reason I donβt understand, the application will try to drop the last view controller that I downloaded to the view controller that I want to display right now. PhotoTakerViewController and WorkZone inherit from the common AppViewController. None of these 3 classes have ExportAttribute
I cannot reproduce this error systematically.
Something strange with this error message is also a fact that it says the application crashed into the WorkZoneSelectorViewController: ViewDidLoad method. But when I try to add some instructions at the beginning of the method, they are never called.
source share