Graphics Programs Reference
In-Depth Information
you haven't selected a row. You haven't selected a row because the list view controller is
not on screen. Why is there no list view controller? In portrait mode, a
UISplitViewController only shows the detail view controller; there isn't enough
space to show the master view controller, too. The split view controller will only display
both when in landscape mode.
Unfortunately, your split view controller will not rotate to landscape mode by default. The
UISplitViewController is a subclass of UIViewController , so it implements
the method shouldAutorotateToInterfaceOrientation: . The method needs
to return YES to allow the rotation and show the master view controller.
Overriding a method requires creating a new subclass, but before we do anything so
drastic, let's look more closely at the implementation of shouldAutorotateToIn-
terfaceOrientation: in UISplitViewController . It looks a bit like this:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)io
{
if ([[self viewControllers] count] == 2) {
UIViewController *master = [[self viewControllers] objectAtIndex:0];
UIViewController *detail = [[self viewControllers] objectAtIndex:1];
return [master shouldAutorotateToInterfaceOrientation:io]
&& [detail shouldAutorotateToInterfaceOrientation:io];
}
return NO;
}
This implementation asks the master and the detail view controller whether it should al-
low rotation. It sends the same message to both view controllers, and if both return YES , it
rotates. So to get the UISplitViewController to allow rotation what we really need
to do is modify the implementation of shouldAutorotateToInterfaceOrient-
ation: in the two view controllers.
In ListViewController.m , override this method to return YES if Nerdfeed is run-
ning on the iPad:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)io
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
return YES;
return io == UIInterfaceOrientationPortrait;
}
Do the same in WebViewController.m :
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)io
{
Search WWH ::




Custom Search