gpt4 book ai didi

ios - MvvmCross iOS : NullReference when using a Custom Presenter for Transitions

转载 作者:行者123 更新时间:2023-12-02 04:42:45 25 4
gpt4 key购买 nike

我遵循了 Stuart 关于 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();

调用堆栈是:

        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#

据我所知,当前没有顶 View Controller ,但我不知道如何设置它,因为我遵循了斯图尔特答案中的所有步骤。 (我无法回复他的答案,因为我的 9 次代表太少了:( )

我已上传一个测试项目,该项目将错误重现到 http://www.cliffcawley.net/TestCustomPresenter.zip

我需要做什么才能使示例正常工作并在单击按钮时看到自定义转换?

最佳答案

模态视图 Controller 显示在其他东西之上。请参阅https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html

我还没有下载您的示例,但从您的堆栈跟踪中我猜测您正在将模式显示为第一个 View - 因此没有任何内容可以在其上显示。

对此的一个简单解决方案是首先尝试显示另一个 View - 即使它只是占位符或背景。

除了简单的解决方案之外,如果您是 uikit 的新手,值得花一些时间来破解一个演示应用程序(非 mvx),您可以在导航 Controller 等中尝试将 View Controller 推送和弹出作为模式,等等 - 一旦您熟悉了有了这个,您就可以在任何 mvx 应用程序中快速编写自己的导航/演示逻辑。

关于ios - MvvmCross iOS : NullReference when using a Custom Presenter for Transitions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21445225/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com