Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 未在演示者词典中配置MvxSidebarPresentationAttribute_C#_Ios_Xamarin_Xamarin.ios_Mvvmcross - Fatal编程技术网

C# 未在演示者词典中配置MvxSidebarPresentationAttribute

C# 未在演示者词典中配置MvxSidebarPresentationAttribute,c#,ios,xamarin,xamarin.ios,mvvmcross,C#,Ios,Xamarin,Xamarin.ios,Mvvmcross,未处理的异常 系统.Collections.Generic.KeyNotFoundException: 未在中配置类型MvxSidebarPresentationAttribute 演示者词典 MvvmCros 5.6工具 Visual studio 2015 Windows 8.1 iPhone7模拟器iOS 10.3 代码 菜单视图 [MvxFromStoryboard("Main")] [MvxSidebarPresentation(MvxPanelEnum.Lef

未处理的异常

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

  • MvvmCros 5.6工具
  • Visual studio 2015
  • Windows 8.1
  • iPhone7模拟器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(“主”)]
[MvxSidebarPresentation(MvxPanelEnum.Left,MvxPanelHintType.PushPanel,false)]
公共部分类MenuViewController:MvxViewController
{
公共菜单IEWController(IntPtr句柄):基本(句柄)
{
}
public MenuViewController():base(“MenuViewController”,null)
{
}
公共覆盖无效DidReceiveMemoryWarning()
{
//如果视图没有superview,则释放该视图。
base.DidReceiveMemoryWarning();
//释放所有未使用的缓存数据、图像等。
}
公共覆盖无效ViewDidLoad()
{
base.ViewDidLoad();
var set=this.CreateBindingSet();
set.Bind(btnFirst).To(vm=>vm.GotoFirstView);
set.Bind(btnSecond).To(vm=>vm.GotoSecondView);
set.Apply();
//加载视图后,通常从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(“主”)]
[MvxSidebarPresentation(MvxPanelEnum.Center,MvxPanelHintType.ResetRoot,true)]
公共部分类FirstViewController:MvxViewController
{
public FirstViewController():base(“FirstViewController”,null)
{
}
公共FirstViewController(IntPtr句柄):基本(句柄)
{
}
公共覆盖无效DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
//释放所有未使用的缓存数据、图像等。
}
公共覆盖无效ViewDidLoad()
{
base.ViewDidLoad();
//加载视图后,通常从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.
        }
    }
[MvxFromStoryboard(“主”)]
[MvxSidebarPresentation(MvxPanelEnum.Center,MvxPanelHintType.ResetRoot,true)]
公共部分类SecondViewController:MvxViewController
{
public SecondViewController():base(“SecondViewController”,null)
{
}
公共SecondViewController(IntPtr句柄):基本(句柄)
{
}
公共覆盖无效DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
//释放所有未使用的缓存数据、图像等。
}
公共覆盖无效ViewDidLoad()
{
base.ViewDidLoad();
//加载视图后,通常从nib执行任何附加设置。
}
}
我已经在我的ios项目中使用了上面的代码,但它只是在ouptut中显示错误
未处理的异常


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

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

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

您可以看到工作示例。

请提供更多详细信息和理想情况下的源代码片段,以便我们能够提供帮助。我已经添加了此override CreatePresenter方法,并查看了您提供的示例,但没有任何更改。您可以为ios中带有mvvm cross的抽屉提供任何其他演示或教程链接。您可以使用在我作为侧边栏演示者的简单教程发送的链接上创建项目-演示项目引发异常未处理的异常:System.NullReferenceException:对象引用未设置为对象的实例现在这很奇怪,我将通过设置
public virtual bool hasshadown=>false来检查是否解决了异常