I have a UIViewController that wants to execute some code when it is dismissed via the leftBarButtonItem (and popped from the stack to return to the parent view controller). This view has subviews of its own so I cannot just use viewWillDisappear.
What is the best way for me to call a custom method when the user presses the left bar button to return to the superview?
Even with subviews you should be able to use
viewWillDisappear.If you need specific actions to be taken on the subviews, run through them in
viewWillDisappearas well.If for some reason you must detect taps on the left bar button item your best bet is to overlay the actual
UINavigationBarfor thatUIViewControllerwith a lookalikeUIImageViewand implement a custom lookalike “back” button on the left side (standard UIButton).Link the custom button to an IBAction and then perform whatever actions you need in there followed by