1#import "SkUISplitViewController.h"
2
3@implementation SkUISplitViewController
4@synthesize fRoot, fDetail;
5
6- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
7    return YES; //Auto Rotation for all orientations
8}
9
10- (void)viewDidLoad {
11    [super viewDidLoad];
12    self.delegate = self;
13    [fDetail populateRoot:fRoot];
14}
15
16- (void)dealloc {
17    [fRoot release];
18    [fDetail release];
19    [super dealloc];
20}
21
22//Table View Delegate Methods
23- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
24    [fDetail goToItem:indexPath.row];
25    if (fRoot.popoverController != nil) {
26        [fRoot.popoverController dismissPopoverAnimated:YES];
27    }
28}
29
30//Split View Controller Delegate
31- (void)splitViewController:(UISplitViewController*)svc
32     willHideViewController:(UIViewController *)aViewController
33          withBarButtonItem:(UIBarButtonItem*)barButtonItem
34       forPopoverController:(UIPopoverController*)pc {
35
36    barButtonItem.title = @"Samples";
37    fRoot.popoverController = pc;
38    fRoot.popoverButtonItem = barButtonItem;
39    [fDetail showRootPopoverButtonItem:fRoot.popoverButtonItem];
40}
41
42- (void)splitViewController:(UISplitViewController*)svc
43     willShowViewController:(UIViewController *)aViewController
44  invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
45    [fDetail invalidateRootPopoverButtonItem:fRoot.popoverButtonItem];
46    fRoot.popoverController = nil;
47    fRoot.popoverButtonItem = nil;
48}
49
50@end
51