title: UINavigationController subclass - customizing Pop
body: <p>Like many others, I would like to perform an action when the 'back' button is used in a UINavigationController.  I am aware of some alternative approaches to this, such as adding my own button and trying to spoof the look, using viewWillDisappear and setting tags on all non-back actions that will cause the view do disappear, etc.</p>
  
  <p>But the one that I would like to try is subclassing UINavigationController and injecting something in popViewControllerAnimated:</p>
  
  <p>But I can't get a simple test case to work.  Here is what I tried...</p>
  
  <p>I created a new class, CustomNavigationController, which inherits from UINavigationController.  In here, I updated popViewControllerAnimated:</p>
  
  <p>.h:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface CustomNavigationController : UINavigationController
  
  @end
  </code></pre>
  
  <p>.m:</p>
  
  <pre><code>#import "CustomNavigationController.h"
  
  @interface CustomNavigationController ()
  
  @end
  
  @implementation CustomNavigationController
  
  - (UIViewController *)popViewControllerAnimated:(BOOL)animated{
      NSLog(@"pop!");
      return [super popViewControllerAnimated:animated];
  }
  
  @end
  </code></pre>
  
  <p>In interface builder, I changed the class of the navigation controller:
  <img src="https://i.stack.imgur.com/a5vdH.png" alt="enter image description here"></p>
  
  <p>What am I missing?  I am expecting 'pop' to be logged whenever I pop any view within this nav controller.</p>