0
votes

I am developing an IOS application with Xamarin using MvvmCross. I want to use a tab bar to navigate between my Views. I want to have only 1 storyboard per View and want to navigate and call my views from code. I've overridden the MvxStoryboardViewsContainer Method CreateViewOfTyp() like the following:

protected override IMvxTouchView CreateViewOfType(Type viewType, 
MvxViewModelRequest request)
    {
        var storyboardAttribute = viewType.GetCustomAttribute<FromStoryboardAttribute>();

        if (storyboardAttribute == null) {
            return base.CreateViewOfType(viewType, request);
        }

        string storyboardName = storyboardAttribute.StoryboardName ?? viewType.Name;

        return
            (IMvxTouchView)
                UIStoryboard.FromName(storyboardName, NSBundle.MainBundle).InstantiateInitialViewController();
    }

Evrytime I try creating my tab bar I call this Method a try to create a View from my model. The Problem I am encountering here is that UIStoryboard I instantiate is of type UIViewController and not MvxViewController (therefor the app crashes when it tries to cast). The actual Controller in question however, should be an MvxViewController!

[FromStoryboard("WorklistView")]
public partial class WorklistViewController : 
MvxViewController<WorklistViewModel>
{
   public WorklistViewController (IntPtr handle) : base (handle)
   {
   }
}

I'm not sure what i'm missing? Why is the Controller i get a UIViewController and not the MvxViewController it should be? Thing is I found a lot about what i am trying to do but i can't figure out what i'm doing different.

1

1 Answers

0
votes

I found my mistake and it was quite a stupid one. My designer class had a different namespace then my controller; god knows why...

Well, it's solved now.