Forum Xamarin.Mac

Manage instances of modal view controller

PhilipJohnPhilipJohn USMember ✭✭

I have an application that presents a modal view controller via a segue when the user taps a button (to view some media). When the user closes the modal I dismiss it from its presentor. However I can see in instruments that the view controller is not released.

When the user taps another item to open the modal again it creates a second instance of the modal view controller.

How can I prevent the second instance being created, or ensure that the first one is released?

Best Answer

  • PhilipJohnPhilipJohn USMember ✭✭
    Accepted Answer

    I'm not sure if this is the only answer to the problem, but it worked for me. I concluded that I couldn't stop the storyboard from creating a new instance of the view controller when I segued to it, so I added the modal view programmatically instead, making sure I could only have one instance of the view controller.

Answers

  • PhilipJohnPhilipJohn USMember ✭✭
    Accepted Answer

    I'm not sure if this is the only answer to the problem, but it worked for me. I concluded that I couldn't stop the storyboard from creating a new instance of the view controller when I segued to it, so I added the modal view programmatically instead, making sure I could only have one instance of the view controller.

Sign In or Register to comment.