Note that there are some explanatory texts on larger screens.

plurals
  1. POUINavigationControllerDelegate methods not called (demo code on github)
    primarykey
    data
    text
    <p>UINavigationControllerDelegate methods not called when poping to a view controller that don't support the current orientation.</p> <p>I have a UINavigationController as root view controller of my app (initial view controller in my Storyboard).</p> <p>Let say I push a ViewController A with this for orientation:</p> <pre><code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } </code></pre> <p>Hence we don't support any landscape mode. On top of that let's push another ViewController with code:</p> <pre><code>@interface B : UIViewController &lt;UINavigationControllerDelegate&gt; @end @implementation B - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; // any orientation supported } - (void)viewDidLoad { [super viewDidLoad]; AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; UINavigationController *nc = (UINavigationController*)appDelegate.window.rootViewController; nc.delegate = self; } - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { // not always called... } - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated { // not always called... } @end </code></pre> <p>Now if I have my iPhone in portrait and I push view controller B on top of A, via some touch event, then touch the "back" button in the navbar, everything is fine and the delegate methods are called (I do some stuff there).</p> <p>But if, when I'm viewing view B, I rotate to landscape, and then hit the back button, those delegate methods are not called!! What's the point of setting a delegate for the UINavigationController if the methods are called sometimes but not other ? Surely I'm doing something wrong.</p> <p>I try to put the delegate in other class, like AppDelegate or my MainView, nothing change.</p> <p>Any ideas ?</p> <p><strong>demo code here:</strong> <a href="http://git://github.com/malaba/NavBarTest.git" rel="nofollow">git://github.com/malaba/NavBarTest.git</a></p> <p>From a basic Master-Detail template, modified just as above.</p> <p>How to show my point ? Here is the step-by-step:</p> <ol> <li>Add some line in Master View (the + top right)</li> <li>then touch a line to go to details view</li> <li>See Log in output showing up</li> <li>Hit back button (labeled "Master"), again log showing up.</li> </ol> <p>Now try to rotate the iPhone (or Simulator) in details view, then go "back" and see <strong>no log</strong> showing up?!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload