c# - 演示者字典中未配置 MvxSidebarPresentationAttribute
<p><blockquote>
<p>Unhandled Exception </p>
<p><strong>System.Collections.Generic.KeyNotFoundException</strong>:
The type MvxSidebarPresentationAttribute is not configured in the
presenter dictionary</p>
</blockquote>
<ul>
<li>MvvmCros 5.6 工具</li>
<li> Visual Studio2015</li>
<li>Windows 8.1</li>
<li>iPhone 7 模拟器 iOS 10.3</li>
</ul>
<p><br/></p>
<p><strong>代码</strong>
<br/>
菜单 View </p>
<pre><code>
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.
}
}
</code></pre>
<p>第一个 View </p>
<pre><code>
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.
}
}
</code></pre>
<p>第二个 View </p>
<pre><code>
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.
}
}
</code></pre>
<p>我在我的 ios 项目中使用了上面的代码,但它只是在输出中显示错误为
<br/>
<strong>未处理的异常</strong></p>
<p><strong>System.Collections.Generic.KeyNotFoundException:</strong>类型 MvxSidebarPresentationAttribute 未在演示者字典中配置</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您必须在您的 iOS 项目的 <code>Setup.cs</code> 文件中使用 <code>MvxSidebarPresenter</code>:</p>
<pre><code>protected override IMvxIosViewPresenter CreatePresenter()
{
return new MvxSidebarPresenter((MvxApplicationDelegate)ApplicationDelegate, Window);
}
</code></pre>
<p>您可以查看工作示例 <a href="https://github.com/MvvmCross/MvvmCross/blob/8218d74b5d005929c047c9e026032323c389aacd/TestProjects/iOS-Support/XamarinSidebar/MvvmCross.iOS.Support.Sidebar/Setup.cs" rel="noreferrer noopener nofollow">in the samples</a> .</p></p>
<p style="font-size: 20px;">关于c# - 演示者字典中未配置 MvxSidebarPresentationAttribute,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/48238699/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/48238699/
</a>
</p>
页:
[1]