对于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);
};
}
}
答案 0 :(得分:1)
ViewModels / Views使用Presenter呈现。
对于导航控制器的模态显示,有些人使用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....
}
或者,如果您想完全自定义视图/视图控制器的表示,那么实现自定义演示器是相当简单的 - 有关更多信息,请参阅{{3中的自定义演示者的一些文章和教程}}
答案 1 :(得分:0)
@wing
您需要做的就是在推送的视图控制器的新视图中添加一个关闭按钮,并覆盖它的touchupinside,如下所示:
private void CloseBtnTouchUpInside(object sender, EventArgs eventArgs)
{
DismissModalViewController(false);
}