2

对于MVVMCross ios,如何使用不同的TransitionalStyle(例如FlipHorizo​​ntal样式)而不是带有“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);
        };
    }
}
4

2 回答 2

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....
    }

或者,如果您想完全自定义视图/视图控制器的呈现,那么实现自定义呈现器是相当简单的 - 有关更多信息,请参阅http://slodge 中有关自定义呈现器的一些文章和教程。 blogspot.co.uk/2013/06/presenter-roundup.html

于 2013-07-18T21:21:06.440 回答
0

@翅膀

您需要做的就是在推送的视图控制器的新视图中添加一个关闭按钮并覆盖它的 touchupinside,如下所示:

private void CloseBtnTouchUpInside(object sender, EventArgs eventArgs)
{
            DismissModalViewController(false);
}
于 2015-05-05T13:23:06.707 回答