首页 \ 问答 \ MvvmCross - 查看未加载(MvvmCross - View not loaded)

MvvmCross - 查看未加载(MvvmCross - View not loaded)

我将一个旧项目升级到Xamarin.iOS Unified和MvvmCross 4.1。

当我运行应用程序时,我得到以下异常:

MvvmCross.Platform.Exceptions.MvxException:未为MyView加载视图

我的课程看起来像:

MyView : MvxViewController<MyViewModel> {}

MvxViewController<T> : UIViewController, IMvxBindingContextOwner, IUIWrappable 
    where T : ViewModelBase

ViewModelBase : MvxViewModel {}

我怀疑我在MyView上缺少接口或其他东西以使MvvmCross正常运行但我不确定这可能是什么接口。

我怀疑这是因为我已经不得不在View和它的ViewModel之间的映射中硬编码,以使MvvmCross能够通过与MyView相关联的反射/自动发现来查找ViewModel。 也就是说,在此错误之前,我无法找到关联的ViewModel错误。

如果我使MyView实现了IMvxIosView,那么这个错误就会消失,然后我会在我的代码中获得ViewModel上的空引用,所以某个地方没有实例化它需要的地方。 我的印象是,这应该由MvvmCross自动处理,但我可能错了。

我正在查看样本,例如https://github.com/MvvmCross/MvvmCross/wiki/Tip-Calc-A-Xamarin.iOS-UI-project

TipView包含的位置

public new TipViewModel ViewModel {
    get { return (TipViewModel) base.ViewModel; }
    set { base.ViewModel = value; }
}

MyView的基础没有这样的ViewModel属性。 我错过了什么才能访问这个?

TipCalc的示例代码仍然引用Cirrious命名空间,因此可能发生了变化。

任何建议表示赞赏。 我是Xamarin和MvvmCross的新手(虽然在Windows / iOS开发方面经验丰富),但我无法找到最新的文档。


I upgraded an old project to Xamarin.iOS Unified and MvvmCross 4.1.

When I run the app, I get the following exception:

MvvmCross.Platform.Exceptions.MvxException: View not loaded for MyView

My classes look like:

MyView : MvxViewController<MyViewModel> {}

MvxViewController<T> : UIViewController, IMvxBindingContextOwner, IUIWrappable 
    where T : ViewModelBase

ViewModelBase : MvxViewModel {}

I suspect I'm missing an interface or something on MyView to enable MvvmCross to operate correctly but I'm not sure what interface this might be.

I suspect this because I already had to hard code in mappings between the View and it's ViewModel, to enable MvvmCross to find the ViewModel through reflection/auto-discovery associated with MyView. That is, before this error, I was getting an unable to find associated ViewModel error.

If I make MyView implement IMvxIosView, this error goes away, and I then get a null reference on the ViewModel later on in my code, so somewhere that is not getting instantiated where it needs to. My impression was this should all be handled automatically by MvvmCross, but I might be wrong.

I'm looking at samples such as https://github.com/MvvmCross/MvvmCross/wiki/Tip-Calc-A-Xamarin.iOS-UI-project

where TipView contains

public new TipViewModel ViewModel {
    get { return (TipViewModel) base.ViewModel; }
    set { base.ViewModel = value; }
}

MyView's base has no such ViewModel property. What am I missing to have access to this?

TipCalc's sample code is still referencing the Cirrious namespace, so it's possible things have changed.

Any suggestions are appreciated. I'm new to Xamarin and MvvmCross (although experienced in Windows/iOS development), and I'm having trouble finding up to date documentation.


原文:https://stackoverflow.com/questions/36583805
更新时间:2022-04-20 10:04

最满意答案

您的问题不在Flash中,而在于您将pdf转换为swf的方式。 pdf2swf的默认参数将导出以前版本的Flash的swf,确切地说是6。 因此,您需要在转换为更高版本时明确设置Flash版本,以便可以在时间轴中导入它(假设您使用的是AS3)。

使用此配置选项:-T,--flashversion num将SWF标头中的Flash版本设置为num。

查看此信息以获取更多信息: http//wiki.swftools.org/index.php title = PDf2swf http://wiki.swftools.org/index.php?title=Pdf2swf_-s_parameters


Your problem is not in Flash but the way you're transforming the pdf to swf. The default parameters of pdf2swf will export the swf for a previous version of Flash, 6 to be exact. So you need to explicitly set the flash version when converting to a later version so that you can import it in your timeline (assuming u're using AS3).

Use this config option: -T , --flashversion num Set Flash Version in the SWF header to num.

View this for more information: http://wiki.swftools.org/index.php?title=Pdf2swf http://wiki.swftools.org/index.php?title=Pdf2swf_-s_parameters

相关问答

更多