从mvvmcross 4.4.0更新到5.0.5后,方法ShowViewModel<SettingsViewModel>();
抛出System.InvalidCastException
。输出是:
mvx:Diagnostic:121.13 Showing ViewModel SettingsViewModel
iOSNavigation:Diagnostic:121.13 Navigate requested
mvx:Diagnostic:121.16 PresentationAttribute not found for SettingsViewController. Assuming animated Child presentation
和StackTrace:
at MvvmCross.iOS.Views.MvxTabBarViewController.ShowChildView (UIKit.UIViewController viewController) [0x00007] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.Presenters.MvxIosViewPresenter.ShowChildViewController (UIKit.UIViewController viewController, MvvmCross.iOS.Views.Presenters.Attributes.MvxChildPresentationAttribute attribute, MvvmCross.Core.ViewModels.MvxViewModelRequest request) [0x0004a] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.Presenters.MvxIosViewPresenter.<RegisterAttributeTypes>b__20_1 (UIKit.UIViewController vc, MvvmCross.iOS.Views.Presenters.Attributes.MvxBasePresentationAttribute attribute, MvvmCross.Core.ViewModels.MvxViewModelRequest request) [0x00000] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.Presenters.MvxIosViewPresenter.Show (MvvmCross.iOS.Views.IMvxIosView view, MvvmCross.Core.ViewModels.MvxViewModelRequest request) [0x0002c] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.Presenters.MvxIosViewPresenter.Show (MvvmCross.Core.ViewModels.MvxViewModelRequest request) [0x00009] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.MvxIosViewDispatcher+<>c__DisplayClass2_0.<ShowViewModel>b__0 () [0x00016] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.MvxIosUIThreadDispatcher.RequestMainThreadAction (System.Action action) [0x0001f] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.iOS.Views.MvxIosViewDispatcher.ShowViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request) [0x00022] in <091ad1c63ffa448eb48cc38964d45708>:0
at MvvmCross.Core.ViewModels.MvxNavigatingObject.ShowViewModelImpl (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterBundle, MvvmCross.Core.ViewModels.IMvxBundle presentationBundle) [0x0002c] in <ed129c02df414c1d8cea008ca80d94cb>:0
at MvvmCross.Core.ViewModels.MvxNavigatingObject.ShowViewModel (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterBundle, MvvmCross.Core.ViewModels.IMvxBundle presentationBundle) [0x00000] in <ed129c02df414c1d8cea008ca80d94cb>:0
at MvvmCross.Core.ViewModels.MvxNavigatingObject.ShowViewModel[TViewModel] (MvvmCross.Core.ViewModels.IMvxBundle parameterBundle, MvvmCross.Core.ViewModels.IMvxBundle presentationBundle) [0x00000] in <ed129c02df414c1d8cea008ca80d94cb>:0
at FreQuest.ViewModels.Tabs.MyProfileViewModel.<get_SettingsCommand>b__35_0 () [0x00001] in /Users/pavlomelnyk/frequest-ios-xamarin/FreQuest/ViewModels/Tabs/MyProfileViewModel.cs:114
at MvvmCross.Core.ViewModels.MvxCommand.Execute (System.Object parameter) [0x00009] in <ed129c02df414c1d8cea008ca80d94cb>:0
at MvvmCross.Binding.iOS.Target.MvxUIControlTargetBinding.ControlEvent (System.Object sender, System.EventArgs eventArgs) [0x00025] in <78be62c59fd541e38ea9b95c6cd03bdc>:0
at UIKit.UIControlEventProxy.Activated () [0x00007] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIControl.cs:38
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at FreQuest.iOS.Application.Main (System.String[] args) [0x00001] in /Users/pavlomelnyk/frequest-ios-xamarin/iOS/Main.cs:17
我在UTabBarController中的MyProfileViewModel中调用ShowViewModel<SettingsViewModel>();
,它扩展了MvxTabBarViewController。我的猜测是以某种方式与TabBarContreller相关的ViewModels没有“看到”SettingsViewController。
有人面临同样的问题吗?您的反馈意见非常有用。
感谢