Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does my navigation controller toolbar overlap my table view when displayed in a split view for the first time?
    text
    copied!<p>I'm working on an iPad application that uses a <code>UISplitViewController</code> as the <code>rootViewController</code> for my window. The detail view controller for the split view is a <code>UINavigationViewController</code> that contains a <code>UITableViewController</code>. Both the split view controller and navigation view controller are created programmatically and do not use a nib. The table view controller is a custom class that extends <code>UITableViewController</code> with the normal table view delegate methods.</p> <p>When the app is running in portrait mode, I can click my button to display my popover and my navigation view and table view show up fine in the popover:</p> <p><img src="https://i.stack.imgur.com/udQOq.png" alt="Popover in portrait"></p> <p>However, the first time that I rotate to landscape and the split view shows the navigation view and table view on the left, the navigation view's toolbar overlaps the first row of the table view:</p> <p><img src="https://i.stack.imgur.com/8CAy1.png" alt="Split view in landscape with table view obscured"></p> <p>You can see that the table view is obscured and the row containing "elephant" cannot be seen. The strange thing is that if I rotate the device back to portrait, then back to landscape again, the table view is no longer obscured:</p> <p><img src="https://i.stack.imgur.com/n7cpD.png" alt="Split view in landscape with table view fully visible"></p> <p>What do I need to do so that the table view displays correctly the first time the device is rotated to landscape?</p> <p><strong>Edit:</strong></p> <p>The <code>UISplitViewController</code> is created in <code>application:didFinishLaunchingWithOptions:</code> and its <code>viewControllers</code> property is set to an array containing my <code>UINavigationController</code> (the master controller in split view parlance) at index 0, and the <code>UIWebView</code>'s controller at index 1.</p> <p>The <code>UINavigationController</code> is created via <code>[[UINavigationController alloc] initWithRootViewController:tableViewController]</code>. The <code>tableViewController</code> instance is a subclass of <code>UITableViewController</code>. Specifically, here is the interface declaration:</p> <pre><code>@interface LocalRevisionsList : UITableViewController &lt;NSFetchedResultsControllerDelegate&gt; {} </code></pre> <p>The tableViewController is initialized thus:</p> <pre><code>tableViewController = [[LocalRevisionList alloc] initWithNibName:@"LocalRevisionList" bundle:nil]; </code></pre> <p>If it's helpful, I can provide information from the .xib. However, even when I initialize the table view without the xib (<code>tableViewController = [[LocalRevisionList alloc] init]</code>), I still see the display problem the first time. The only overridden operations in <code>LocalRevisionList</code> is <code>viewDidLoad</code>. Here it is in full (just to show we're not doing anything wacky here):</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; self.title = @"My Title"; NSError *error; if (![[self fetchedResultsController] performFetch:&amp;error]) { abort(); } } </code></pre> <p><strong>Edit 2:</strong></p> <p>I did not create this project using the Split View template project, but I've been referring to that trying to find the difference between what I'm doing and what that project does. The only difference I've found is that the template project sets up the split view and its child view controllers inside the .xib, whereas I create most of my controllers programatically.</p> <p>When I break inside <code>shouldAutorotateToInterfaceOrientation:</code> and dump the root view controller's frame, I see:</p> <pre><code>(gdb) print (CGRect)[[self view] frame] $2 = { origin = { x = 0, y = 0 }, size = { width = 768, height = 1004 } } </code></pre> <p>Printing the frame of my navigation controller which is the first controller in my split view array, I see this:</p> <pre><code>(gdb) print (CGRect)[[[self localArticlesNavController] view] frame] $3 = { origin = { x = -320, y = 0 }, size = { width = 320, height = 1004 } } </code></pre> <p>The negative x value is interesting, but I don't think it's causing me the problem here. Even when I rotate back to portrait, then back to landscape again, these frame values are the same as they were the first time (when the view displays incorrectly).</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