Graphics Programs Reference
In-Depth Information
a split view controller, but it makes using the bar button item much easier. (If you don't
use a navigation controller, you can instantiate your own UINavigationBar or
UIToolbar to hold the bar button item and add it as a subview of the WebViewCon-
troller 's view.)
There are two small issues left to address with your List button. First, when the device is
rotated back to landscape mode, the button is still there. To remove it, the delegate needs
to respond to another message from the UISplitViewController . Implement this
delegate method in WebViewController.m .
- (void)splitViewController:(UISplitViewController *)svc
willShowViewController:(UIViewController *)aViewController
invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
// Remove the bar button item from our navigation item
// We'll double check that its the correct button, even though we know it is
if (barButtonItem == [[self navigationItem] leftBarButtonItem])
[[self navigationItem] setLeftBarButtonItem:nil];
}
Build and run the application. The List button will now appear and disappear as you rotate
between portrait and landscape modes.
The second issue is that the ChannelViewController also needs to show the List
button. In ChannelViewController.m , implement the two UISplitViewCon-
trollerDelegate methods.
- (void)splitViewController:(UISplitViewController *)svc
willHideViewController:(UIViewController *)aViewController
withBarButtonItem:(UIBarButtonItem *)barButtonItem
forPopoverController:(UIPopoverController *)pc
{
[barButtonItem setTitle:@"List"];
[[self navigationItem] setLeftBarButtonItem:barButtonItem];
}
- (void)splitViewController:(UISplitViewController *)svc
willShowViewController:(UIViewController *)aViewController
invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
if (barButtonItem == [[self navigationItem] leftBarButtonItem])
[[self navigationItem] setLeftBarButtonItem:nil];
}
Build and run the application. Now the List button will also appear on the navigation bar
when the ChannelViewController is on the screen.
Search WWH ::




Custom Search