Note that there are some explanatory texts on larger screens.

plurals
  1. POUISplitViewController delegate methods not called
    text
    copied!<p>I am using a <code>UISplitViewController</code> inside a <code>UITabBarController</code> with a plain <code>UIViewController</code> in the master pane of the split view and a <code>UINavigationController</code> in the detail pane, which itself contains a vanilla <code>UIViewController</code>.</p> <p>I am aware that Apple advise to use split views at the root level only, however I have seen other applications (eg, Amazon- 'Wish List' tab) that use split views in tabs so I'm sure it's possible.</p> <p>My problem is that the delegate methods of the split view, ie. those in <code>UISplitViewControllerDelegate</code> do not get called, which prevents me from creating my pop-over menu when switching into Portrait mode.</p> <p>The methods in question are the following -</p> <pre><code>// Called when a button should be added to a toolbar for a hidden view controller - (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc; // Called when the view is shown again in the split view, invalidating the button and popover controller - (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem; // Called when the view controller is shown in a popover so the delegate can take action like hiding other popovers. - (void)splitViewController: (UISplitViewController*)svc popoverController: (UIPopoverController*)pc willPresentViewController:(UIViewController *)aViewController; </code></pre> <p>The <code>UISplitViewController</code> <strong>does</strong> receive the rotation notifications.</p> <p>I can get the <em>willShowViewController</em> method to be called if I force the status bar orientation to landscape right (or left) at the beginning of the app launch, using</p> <pre><code> [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight]; </code></pre> <p>However, the <code>willHideViewController</code> doesn't get called. And I don't want to force the app to start in landscape. If I do the same thing but force it to portrait, I don't receive the callbacks.</p> <p>I don't understand why the split view controller is not calling it's delegate methods when it is otherwise behaving correctly. These methods should be called from its method-</p> <pre><code>- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration </code></pre> <p>internally, and when I breakpoint inside this, I can check that the delegate is set and that it is still alive. </p> <p>Been stuck on this all day! Everything else is working great and I'm very pleased that the splitview / tabbar / navbar combination is working well. I just need these notifications.</p> <p>Should I perhaps just call them manually when I rotate? Seems very wrong when the `UISplitViewController' should be doing this.</p>
 

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