显示MvxTabBarViewController mvvmcross ios时的NullReference
我在xCode上制作了一个故事板,我知道我正在与Xamarin和mvvmcross一起在visual studio上工作,用相同的内核制作IOS和Android应用程序。 我的故事板有一些视图(包括一些初始视图上的侧栏),它们将打开4个视图,这些视图将调用显示MvxTabBarViewController mvvmcross ios时的NullReference,ios,xamarin,uitabbarcontroller,mvvmcross,sidebar,Ios,Xamarin,Uitabbarcontroller,Mvvmcross,Sidebar,我在xCode上制作了一个故事板,我知道我正在与Xamarin和mvvmcross一起在visual studio上工作,用相同的内核制作IOS和Android应用程序。 我的故事板有一些视图(包括一些初始视图上的侧栏),它们将打开4个视图,这些视图将调用MvxTabBarViewController的ShowViewModel,每个视图将打开不同的选项卡 所有4视图的导航都完成了,现在我在显示选项卡栏时遇到问题 当我尝试调用ShowViewModel到MvxTabBarViewControll
MvxTabBarViewController
的ShowViewModel
,每个视图将打开不同的选项卡
所有4视图的导航都完成了,现在我在显示选项卡栏时遇到问题
当我尝试调用ShowViewModel
到MvxTabBarViewController
并打开一个特定选项卡时,在该选项卡的viewdiload
上,我出现了错误
System.NullReferenceException:对象引用未设置为实例
物体的形状
我的标签栏的结构都是在故事板上创建的
以下是我的选项卡控制器的代码:
[MvxFromStoryboard("Main")]
[MvxSidebarPresentation(MvxPanelEnum.Center, MvxPanelHintType.PushPanel, true)]
public partial class TabDetailView : MvxTabBarViewController<TabDetailViewModel>
{
private bool _constructed;
public TabDetailView(IntPtr handle) : base(handle)
{
_constructed = true;
// need this additional call to ViewDidLoad because UIkit creates the view before the C# hierarchy has been constructed
ViewDidLoad();
}
public TabDetailView()
{
_constructed = true;
// need this additional call to ViewDidLoad because UIkit creates the view before the C# hierarchy has been constructed
ViewDidLoad();
}
public override void ViewDidLoad()
{
if (!_constructed)
return;
base.ViewDidLoad();
var vm = (TabDetailViewModel)this.ViewModel;
if (vm == null)
return;
}
}
[MvxFromStoryboard(“主”)]
[MvxSidebarPresentation(MvxPanelEnum.Center,MvxPanelHintType.PushPanel,true)]
公共部分类TabDetailView:MvxTabBarViewController
{
私人建筑;
公共选项卡DetailView(IntPtr句柄):基本(句柄)
{
_构造=真;
//需要额外调用ViewDidLoad,因为UIkit在构建C#层次结构之前创建视图
ViewDidLoad();
}
公共选项卡DetailView()
{
_构造=真;
//需要额外调用ViewDidLoad,因为UIkit在构建C#层次结构之前创建视图
ViewDidLoad();
}
公共覆盖无效ViewDidLoad()
{
如果(!\u构造)
返回;
base.ViewDidLoad();
var vm=(TabDetailViewModel)this.ViewModel;
if(vm==null)
返回;
}
}
下面是我要打开的选项卡对应的ViewController代码:
[MvxFromStoryboard("Main")]
[MvxSidebarPresentation(MvxPanelEnum.Center, MvxPanelHintType.PushPanel, true)]
public partial class TabDiaryView : MvxViewController<TabDiaryViewModel>
{
public TabDiaryView (IntPtr handle) : base (handle)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad(); //HERE IS THE ERROR (NULLREFERENCE)
}
}
public class Setup : MvxIosSetup
{
public Setup(MvxApplicationDelegate applicationDelegate, UIWindow window)
: base(applicationDelegate, window)
{
}
public Setup(MvxApplicationDelegate applicationDelegate, IMvxIosViewPresenter presenter)
: base(applicationDelegate, presenter)
{
}
protected override IMvxApplication CreateApp()
{
return new Core.App();
}
protected override IMvxTrace CreateDebugTrace()
{
return new DebugTrace();
}
protected override IMvxIosViewPresenter CreatePresenter()
{
return new MvxSidebarPresenter((MvxApplicationDelegate)ApplicationDelegate, Window);
}
}
[MvxFromStoryboard(“主”)]
[MvxSidebarPresentation(MvxPanelEnum.Center,MvxPanelHintType.PushPanel,true)]
公共部分类TabDiaryView:MvxViewController
{
公共选项卡DiaryView(IntPtr句柄):基本(句柄)
{
}
公共覆盖无效ViewDidLoad()
{
base.ViewDidLoad();//以下是错误(NULLREFERENCE)
}
}
公共类设置:MvxIosSetup
{
公共设置(MVXApplicationLegate applicationLegate,UIWindow)
:基本(ApplicationLegate,窗口)
{
}
公共设置(MVXApplicationLegate应用程序Legate、IMvxIosViewPresenter演示器)
:base(ApplicationLegate、演示者)
{
}
受保护的覆盖IMvxApplication CreateApp()
{
返回新的Core.App();
}
受保护的覆盖IMVXStrace CreateDebugTrace()
{
返回新的DebugTrace();
}
受保护的覆盖IMvxIosViewPresenter CreatePresenter()
{
返回新的MvxSidebarPresenter((MVXApplicationLegate)applicationLegate,窗口);
}
}
请帮帮我