我在MVVMCross iOS: how to bind a command with Custom transition when switching to different View model
上听取了斯图尔特的建议当我切换到使用从MvxModalNavSupportTouchViewPresenter派生的自定义演示者时,我的应用程序在调用.Start()时,AppDelegate :: FinishedLaunching中崩溃(System.NullReferenceException:对象引用未设置为对象的实例):
IMvxAppStart startup = Mvx.Resolve<IMvxAppStart>();
startup.Start();
Callstack是:
0x7 in Cirrious.MvvmCross.Touch.Views.Presenters.MvxTouchViewPresenter.get_CurrentTopViewController C#
0x2 in Cirrious.MvvmCross.Touch.Views.Presenters.MvxTouchViewPresenter.PresentModalViewController C#
0x4E in Cirrious.MvvmCross.Touch.Views.Presenters.MvxModalNavSupportTouchViewPresenter.Show C#
0xB in Cirrious.MvvmCross.Touch.Views.Presenters.MvxTouchViewPresenter.Show C#
0x28 in Cirrious.MvvmCross.Touch.Views.MvxTouchViewDispatcher. C#
0x28 in Cirrious.MvvmCross.Touch.Views.MvxTouchUIThreadDispatcher.RequestMainThreadAction C#
0x24 in Cirrious.MvvmCross.Touch.Views.MvxTouchViewDispatcher.ShowViewModel C#
0x30 in Cirrious.MvvmCross.ViewModels.MvxNavigatingObject.ShowViewModelImpl C#
0x6 in Cirrious.MvvmCross.ViewModels.MvxNavigatingObject.ShowViewModel C#
0xE in Cirrious.MvvmCross.ViewModels.MvxNavigatingObject.ShowViewModel<TestCustomPresenter.Core.ViewModels.FirstViewModel> C#
0x17 in Cirrious.MvvmCross.ViewModels.MvxAppStart<TestCustomPresenter.Core.ViewModels.FirstViewModel>.Start C#
> 0x3A in TestCustomPresenter.iOS.AppDelegate.FinishedLaunching at e:\Src\test\TestCustomPresenter\TestCustomPresenter.iOS\AppDelegate.cs:54 C#
0x9F in MonoTouch.UIKit.UIApplication.UIApplicationMain C#
0x52 in MonoTouch.UIKit.UIApplication.Main at /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 C#
0x8 in TestCustomPresenter.iOS.Application.Main at e:\Src\test\TestCustomPresenter\TestCustomPresenter.iOS\Main.cs:23 C#
据我所知,目前没有顶级视图控制器,但我不知道如何设置它,因为我按照Stuart的答案执行了所有步骤。 (我无法回答他的回答,因为我有9个代表太少了:()
我上传了一个将错误重现为http://www.cliffcawley.net/TestCustomPresenter.zip
的测试项目如何让示例工作并在单击按钮时查看自定义转换,我该怎么办?
答案 0 :(得分:2)
模态视图控制器显示在其他内容之上。见https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html
我没有下载你的样本,但是从你的堆栈跟踪我的猜测是你将模态显示为你的第一个视图 - 所以没有任何东西可以显示它。
一个简单的解决方案是首先尝试显示另一个视图 - 即使它只是一个占位符或背景。
除了简单的解决方案之外,如果你是uikit的新手,那么你需要花一些时间来破解一个演示应用程序(非mvx),你可以尝试在视图控制器中推送和弹出视图控制器,在导航控制器中等等 - 一旦你感觉舒服有了这个,那么你可以在任何mvx应用程序中快速编写自己的导航/表示逻辑。