I have a view controller where I need to add a custom back button. So I have added a custom backButtonItem
. But After adding custom back button the default behavior of my view controller to go back by swipe stops working as expected.
If I remove the custom back button from the view controller, the behavior of view controller is as expected but as soon as I add custom back button the default behavior stops.
I have added the custom back button like this
self.navigationItem.leftBarButtonItem = getCustomBackBarButtonItem(viewController: self)
I have tried to use backBarButtonItem
instead of leftBarButtonItem
, but by doing that the custom back button doesn't appear and the view controller's behavior is as expected.
If I remove the above code the behavior of the view controller is as expected and it smoothly goes back by swipe.