Sidemenu: Memory leak with storyboard approach !

Created on 9 Jul 2018  路  1Comment  路  Source: jonkykong/SideMenu

Hi ,
I did follow the steps in ReadMe

I made a TableViewController
with Navigation controller and I choose SideMenu as a class for Navigation controller

Then I make multiple cells in TableViewController
And connect every cell with another viewController using Segue

Everything is fine as what it said in Readme

what isn''t clear is
How I open Side Menu ?

So I made a Segue "Show" from every Hamburger button to Navigation controller

and I think that will make Memory leak
after a while using the app
and going between view controllers using side menu !

What Is a good approach to avoid that ?

Most helpful comment

I found the solution :

The push style of the menu.

There are six modes in MenuPushStyle:

  • defaultBehavior: The view controller is pushed onto the stack.
  • popWhenPossible: If a view controller already in the stack is of the same class as the pushed view controller, the stack is instead popped back to the existing view controller. This behavior can help users from getting lost in a deep navigation stack.
  • preserve: If a view controller already in the stack is of the same class as the pushed view controller, the existing view controller is pushed to the end of the stack. This behavior is similar to a UITabBarController.
  • preserveAndHideBackButton: Same as .preserve and back buttons are automatically hidden.
  • replace: Any existing view controllers are released from the stack and replaced with the pushed view controller. Back buttons are automatically hidden. This behavior is ideal if view controllers require a lot of memory or their state doesn't need to be preserved.
  • subMenu: Unlike all other behaviors that push using the menu's presentingViewController, this behavior pushes view controllers within the menu. Use this behavior if you want to display a sub menu.

I used

    SideMenuManager.default.menuPushStyle = .preserveAndHideBackButton

and it solved my issue

I hope to see these options
on Storyboard

with Left Side option !

>All comments

I found the solution :

The push style of the menu.

There are six modes in MenuPushStyle:

  • defaultBehavior: The view controller is pushed onto the stack.
  • popWhenPossible: If a view controller already in the stack is of the same class as the pushed view controller, the stack is instead popped back to the existing view controller. This behavior can help users from getting lost in a deep navigation stack.
  • preserve: If a view controller already in the stack is of the same class as the pushed view controller, the existing view controller is pushed to the end of the stack. This behavior is similar to a UITabBarController.
  • preserveAndHideBackButton: Same as .preserve and back buttons are automatically hidden.
  • replace: Any existing view controllers are released from the stack and replaced with the pushed view controller. Back buttons are automatically hidden. This behavior is ideal if view controllers require a lot of memory or their state doesn't need to be preserved.
  • subMenu: Unlike all other behaviors that push using the menu's presentingViewController, this behavior pushes view controllers within the menu. Use this behavior if you want to display a sub menu.

I used

    SideMenuManager.default.menuPushStyle = .preserveAndHideBackButton

and it solved my issue

I hope to see these options
on Storyboard

with Left Side option !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vkolosovsky picture vkolosovsky  路  4Comments

tush010 picture tush010  路  3Comments

selaysoysal picture selaysoysal  路  7Comments

szooky picture szooky  路  5Comments

CaliCastle picture CaliCastle  路  3Comments