未在演示者字典中配置MvxSidebarPresentationAttribute

时间:2018-01-13 09:50:07

标签: c# ios xamarin xamarin.ios mvvmcross

  

未处理的例外

     

System.Collections.Generic.KeyNotFoundException :   类型MvxSidebarPresentationAttribute未在中配置   演讲者词典

  • MvvmCros 5.6工具
  • Visual Studio 2015
  • Windows 8.1
  • iPhone 7模拟器iOS 10.3



菜单视图

    [MvxFromStoryboard("Main")]
    [MvxSidebarPresentation(MvxPanelEnum.Left, MvxPanelHintType.PushPanel, false)]
    public partial class MenuViewController : MvxViewController<MenuViewModel>
    {
        public MenuViewController(IntPtr handle) : base(handle)
        {
        }

        public MenuViewController() : base("MenuViewController", null)
        {
        }

        public override void DidReceiveMemoryWarning()
        {
            // Releases the view if it doesn't have a superview.
            base.DidReceiveMemoryWarning();

            // Release any cached data, images, etc that aren't in use.
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var set = this.CreateBindingSet<MenuViewController, MenuViewModel>();
            set.Bind(btnFirst).To(vm => vm.GotoFirstView);
            set.Bind(btnSecond).To(vm => vm.GotoSecondView);
            set.Apply();
            // Perform any additional setup after loading the view, typically from a nib.
        }
}

首先查看

[MvxFromStoryboard("Main")]
[MvxSidebarPresentation(MvxPanelEnum.Center, MvxPanelHintType.ResetRoot, true)]
public partial class FirstViewController : MvxViewController<FirstViewModel>
{
    public FirstViewController() : base("FirstViewController", null)
    {
    }

    public FirstViewController(IntPtr handle) : base(handle)
    {
    }
    public override void DidReceiveMemoryWarning()
    {
        base.DidReceiveMemoryWarning();

        // Release any cached data, images, etc that aren't in use.
    }

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        // Perform any additional setup after loading the view, typically from a nib.
    }
}

第二种观点

[MvxFromStoryboard("Main")]
    [MvxSidebarPresentation(MvxPanelEnum.Center, MvxPanelHintType.ResetRoot, true)]
    public partial class SecondViewController : MvxViewController<SecondViewModel>
    {
        public SecondViewController() : base("SecondViewController", null)
        {
        }

        public SecondViewController(IntPtr handle) : base(handle)
        {
        }

        public override void DidReceiveMemoryWarning()
        {
            base.DidReceiveMemoryWarning();

            // Release any cached data, images, etc that aren't in use.
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.
        }
    }

我在我的ios项目中使用了上面的代码,但它只显示了ouptut中的错误
未处理的例外

System.Collections.Generic.KeyNotFoundException:未在演示者词典中配置MvxSidebarPresentationAttribute类型

1 个答案:

答案 0 :(得分:3)

您必须使用iOS项目的MvxSidebarPresenter文件中的Setup.cs

protected override IMvxIosViewPresenter CreatePresenter()
{
   return new MvxSidebarPresenter((MvxApplicationDelegate)ApplicationDelegate, Window);
}

您可以看到工作示例in the samples