aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/iOSSampleApp/Shared/SkUIRootViewController.mm
blob: 255a2711dd6e98bc19e1543cf442e7573fd81ee2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#import "SkUIRootViewController.h"
#import "SkUISplitViewController.h"
@implementation SkUIRootViewController
@synthesize popoverController, popoverButtonItem;

//Overwritten from UIViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.contentSizeForViewInPopover = CGSizeMake(200, self.view.bounds.size.height);
    fSamples = [[NSMutableArray alloc] init];
}

- (void)viewDidUnload {
    [super viewDidUnload];
    self.popoverButtonItem = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

- (void)dealloc {
    [popoverController release];
    [popoverButtonItem release];
    [fSamples release];
    [super dealloc];
}


//Table View Delegate Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [fSamples count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                       reuseIdentifier:CellIdentifier] autorelease];
    }

    cell.textLabel.text = [fSamples objectAtIndex:indexPath.row];
    return cell;
}

//Instance methods
- (void)addItem:(NSString*)anItem {
    [fSamples addObject:anItem];
}

@end