代码之家  ›  专栏  ›  技术社区  ›  Mayur Kerasiya

未在presenter字典中配置MvxSidebarPresentationAttribute

  •  2
  • Mayur Kerasiya  · 技术社区  · 6 年前

    未处理的异常

    系统收藏。通用的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中显示错误为
    未处理的异常

    系统收藏。通用的KeyNotFoundException: 未在presenter字典中配置类型MvxSidebarPresentationAttribute

    1 回复  |  直到 6 年前
        1
  •  3
  •   Martin Zikmund    6 年前

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

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

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