Graphics Programs Reference
In-Depth Information
When this button is tapped, the detail view controller in the split view will be replaced
with an instance of ChannelViewController . In ListViewController.m , im-
plement the action method to create an instance of ChannelViewController . Then
check for a split view controller and set the split view controller's viewControllers
array.
#import "ChannelViewController.h"
@implementation ListViewController
- (void)showInfo:(id)sender
{
// Create the channel view controller
ChannelViewController *channelViewController = [[ChannelViewController alloc]
initWithStyle:UITableViewStyleGrouped];
if ([self splitViewController]) {
UINavigationController *nvc = [[UINavigationController alloc]
initWithRootViewController:channelViewController];
// Create an array with our nav controller and this new VC's nav controller
NSArray *vcs = [NSArray arrayWithObjects:[self navigationController],
nvc,
nil];
// Grab a pointer to the split view controller
// and reset its view controllers array.
[[self splitViewController] setViewControllers:vcs];
// Make detail view controller the delegate of the split view controller
// - ignore this warning
[[self splitViewController] setDelegate:channelViewController];
// If a row has been selected, deselect it so that a row
// is not selected when viewing the info
NSIndexPath *selectedRow = [[self tableView] indexPathForSelectedRow];
if (selectedRow)
[[self tableView] deselectRowAtIndexPath:selectedRow animated:YES];
} else {
[[self navigationController] pushViewController:channelViewController
animated:YES];
}
// Give the VC the channel object through the protocol message
[channelViewController listViewController:self handleObject:channel];
}
Notice that here again you have left a non-split view controller, non-iPad option in an
else clause that pushes the ChannelViewController onto the navigation control-
ler's stack.
Build and run the application. After the RSS feed loads, tap the Info button. The detail
view controller will display the metadata for the channel. However, if you tap on a post
after you've loaded the metadata, nothing will happen - you can't get back to a web view.
Search WWH ::




Custom Search