MVVMCross iOS:当切换到不同的View模型时,如何将自定义转换绑定命令
对于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呈现。
对于导航控制器的Modal显示器,有些人使用MvxModalNavSupportTouchViewPresenter.cs
您可以通过在设置中重写CreatePresenter
来使用此演示者:
protected override IMvxTouchViewPresenter CreatePresenter() { return new MvxModalNavSupportTouchViewPresenter(ApplicationDelegate, Window); }
完成此操作后,您应该能够通过添加IMvxModalTouchView
inheritance并设置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
@翅膀
所有你需要做的是添加一个closuresbutton到推视图控制器的新视图,并覆盖它的touchupinside如下:
private void CloseBtnTouchUpInside(object sender, EventArgs eventArgs) { DismissModalViewController(false); }
- UIPageViewController在内存不足时翻转速度过快时会崩溃
- unregisterForRemoteNotifications不适用于iOS8 – 推送通知
- 蓝光音乐– BEL –不再哭泣–蓝光音乐–中
- CloudKit:CKFetchRecordChangesOperation,CKServerChangeToken和Delta Download
- IOS SDK – 如何截屏tableView的内容?
- Google地图折线不完美
- 调用becomeFirstResponder时,UITextView使应用程序崩溃
- 是否有可能在UIScrollView放大和缩小UIImageView,但坚持自动布局居中?
- Firebase:提供的存储桶与Swift中当前实例的存储存储桶不匹配