MvvmCross iOS: how to reject a view controller when using IMvxModelTouchView

I used IMvXModelTouchView to custom animate pop-ups. And I have a close button for this tooltip. How can I return to the previous view?

Here is my code as follows:

public class PopupView : MvxViewController, IMvxModalTouchView { public PopupView() { ModalPresentationStyle = UIModalPresentationStyle.PageSheet; } public override void ViewDidLoad() { Title = "Map"; base.ViewDidLoad(); var closeButton = new UIButton(new RectangleF(0, 0, 50, 30)); closeButton.TouchUpInside += CloseButtonClicked(); Add(closeButton); } private EventHandler CloseButtonClicked() { return (sender, args) => NavigationController.DismissViewController(true, null); } } 

It worked when I click this close button, but it crashes when I try to open this view again.

+4
source share
1 answer

I suspect you are probably using the standard MvxModalSupportTouchViewPresenter , which expects only one modal view / viewModel, and which expects the view / viewModel to be cleared using Close(this) from the ViewModel.

See: MvxModalSupportTouchViewPresenter.cs # L29

If you have strong ideas regarding your user interface, then (in my opinion) it is best to write your own interlocutor - then you can open / close / hide / show whatever you want. For more information on writing custom presenters, see some links and videos: http://slodge.blogspot.com/2013/06/presenter-roundup.html

+4
source

Source: https://habr.com/ru/post/1492393/


All Articles