Memory leak in MvxBaseViewController in MvvmCross-iOSSupport?

I am using the MvxBaseViewController from the iOS Support Library to handle the keyboard.

Having canceled the deletion, I noticed that my view, which inherits from the MvxBaseViewController, is not collected by the GC when it is pulled out of the navigation controller.

When I add the following to the MvxBaseViewController ...

public override void ViewWillDisappear(bool animated)
    {
        base.ViewWillDisappear(animated);

        this.UnregisterForKeyboardNotifications();

        this.View.RemoveGestureRecognizer(this.tap);
    }

... and when I add / remove a ShouldReturn delegate in my view like this ...

public override void ViewWillAppear(bool animated)
{
    base.ViewWillAppear(animated);
    this.myTextField.ShouldReturn += this.TextFieldShouldReturn;
}

public override void ViewWillDisappear(bool animated)
{
    base.ViewWillDisappear(animated);
    this.myTextField.ShouldReturn -= this.TextFieldShouldReturn;
}

.. then my view is deleted.

I start with MvvmCross and memory management in Xamarin, so my questions are:

Do I have any flaws with these workarounds? Is this the right way to solve this problem?

+4
source share

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


All Articles