I am working on an app which was previously developed without using Storyboards, i.e. all the views were created in code. So as per this link, I am trying to pass a custom MvxTouchViewsContainer
to MvxTouchSetup.CreateTouchViewsContainer
.
protected override IMvxTouchView CreateViewOfType(Type viewType, MvxViewModelRequest request)
{
UIStoryboard storyboard;
try
{
storyboard = UIStoryboard.FromName(viewType.Name, null);
}
catch (Exception)
{
try {
storyboard = UIStoryboard.FromName("MainStoryBoard_iPhone", null);
}
catch (Exception) {
return base.CreateViewOfType (viewType, request);
}
}
IMvxTouchView resultView = null;
try {
resultView = (IMvxTouchView) storyboard.InstantiateViewController(viewType.Name);
} catch(Exception) {
resultView = base.CreateViewOfType (viewType, request);
}
return resultView;
}
Basically I try to find a storyboard if present, else I fallback to loading the view from code. The try - catch exceptions works fine in the simulator. However, the exceptions are not getting caught when running on an actual iOS Device and the app is crashing.
I get a MonoTouch.Foundation.MonoTouchException which contains NSInvalidArgumentException which basically is expected because, some views may not have a storyboard associated with them.
Is this a Xamarin bug?