I'm working on an iPad application that uses a UISplitViewController
as the rootViewController
for my window. The detail view controller for the split view is a UINavigationViewController
that contains a UITableViewController
. 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 UITableViewController
with the normal table view delegate methods.
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:
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:
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:
What do I need to do so that the table view displays correctly the first time the device is rotated to landscape?
Edit:
The UISplitViewController
is created in application:didFinishLaunchingWithOptions:
and its viewControllers
property is set to an array containing开发者_如何学Python my UINavigationController
(the master controller in split view parlance) at index 0, and the UIWebView
's controller at index 1.
The UINavigationController
is created via [[UINavigationController alloc] initWithRootViewController:tableViewController]
. The tableViewController
instance is a subclass of UITableViewController
. Specifically, here is the interface declaration:
@interface LocalRevisionsList :
UITableViewController <NSFetchedResultsControllerDelegate> {}
The tableViewController is initialized thus:
tableViewController =
[[LocalRevisionList alloc] initWithNibName:@"LocalRevisionList" bundle:nil];
If it's helpful, I can provide information from the .xib. However, even when I initialize the table view without the xib (tableViewController = [[LocalRevisionList alloc] init]
), I still see the display problem the first time. The only overridden operations in LocalRevisionList
is viewDidLoad
. Here it is in full (just to show we're not doing anything wacky here):
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"My Title";
NSError *error;
if (![[self fetchedResultsController] performFetch:&error])
{
abort();
}
}
Edit 2:
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.
When I break inside shouldAutorotateToInterfaceOrientation:
and dump the root view controller's frame, I see:
(gdb) print (CGRect)[[self view] frame]
$2 = {
origin = {
x = 0,
y = 0
},
size = {
width = 768,
height = 1004
}
}
Printing the frame of my navigation controller which is the first controller in my split view array, I see this:
(gdb) print (CGRect)[[[self localArticlesNavController] view] frame]
$3 = {
origin = {
x = -320,
y = 0
},
size = {
width = 320,
height = 1004
}
}
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).
精彩评论