对于 MVVMCross ios,如何使用不同的 TransitionalStyle(例如 FlipHorizontal 样式)而不是使用“ShowViewModel”的默认滑动效果?
[Register("SearchResults")]
public class SearchResultsView : MvxTableViewController
{
public override void ViewDidLoad()
{
Title = "List";
base.ViewDidLoad();
var mapButton = new UIButton(new RectangleF(0, 0, 65, 30));
mapButton.SetBackgroundImage(UIImage.FromBundle("images/map_btn.png"), UIControlState.Normal);
mapButton.TouchUpInside += MapButtonClicked();
var rightButton = new UIBarButtonItem(mapButton);
NavigationItem.RightBarButtonItem = rightButton;
var bindings = this.CreateBindingSet<SearchResultsView, SearchResultsViewModel>();
//bindings.Bind(mapButton).To(x => x.ShowMapCommand); //how to do with binding command?
bindings.Apply();
}
private EventHandler MapButtonClicked()
{
return (sender, args) =>
{
var mapView = new SearchResultMapView {ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal};
var navigationController = new UINavigationController(mapView);
PresentViewController(navigationController, true, null);
};
}
}
最佳答案
ViewModels/Views 使用 Presenter 呈现。
对于导航 Controller 的模态显示,有些人使用 MvxModalNavSupportTouchViewPresenter.cs
您可以通过覆盖设置中的 CreatePresenter
来使用此演示器:
protected override IMvxTouchViewPresenter CreatePresenter()
{
return new MvxModalNavSupportTouchViewPresenter(ApplicationDelegate, Window);
}
完成此操作后,您应该能够通过添加 IMvxModalTouchView
继承并在构造函数中为您的 设置
.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal;
来实现过渡效果>SearchResultMapView
public class SearchResultMapView
: MvxViewController, IMvxModalTouchView
{
public SearchResultMapView()
{
ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal;
}
// more code here....
}
或者,如果您想完全自定义 View / View Controller 的呈现,那么实现自定义呈现器是相当简单的 - 有关更多信息,请参阅 http://slodge.blogspot.co.uk/2013/06/presenter-roundup.html 中有关自定义呈现器的一些文章和教程。
关于ios - MVVM跨iOS : how to bind a command with Custom transition when switching to different View model,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17731568/