我已更新到mvvmcross 4.我正在使用故事板,并且无法通过viewmodel(pcl)启动控制器。
有人有样品吗?我在mvvmcross页面上找到了一个示例,但是他们使用了xib,在使用故事板时它无法正常工作。
任何帮助都会很棒!
答案 0 :(得分:2)
查看MvxFromStoryboard
属性,如https://forums.xamarin.com/discussion/45253/cross-platform-development-with-mvvmcross
// Will look for a UIViewController with identifier "MyView" inside a Storyboard named "MyView.storyboard"
[MvxFromStoryboard]
public class MyView : MvxViewController
{
public MyView(IntPtr handle) : base(handle) {}
}
// Will look for a UIVIewController with identifier "MyOtherViewInSameStoryboard" inside a Storyboard named "MyView.storyboard"
[MvxFromStoryboard(StoryboardName = "MyView")]
public class MyOtherViewInSameStoryboard : MvxViewController
{
public MyOtherViewInSameStoryboard(IntPtr handle) : base(handle) {}
}
ViewModel
通过命名惯例与ViewController
相关联。
XYZ ViewModel~>的 XYZ 强>的ViewController