yangsu@google.com | 2eff7e2 | 2011-06-24 15:57:30 +0000 | [diff] [blame^] | 1 | #import "SkUIRootViewController.h" |
| 2 | #import "SkUISplitViewController.h" |
| 3 | @implementation SkUIRootViewController |
| 4 | |
| 5 | @synthesize popoverController, popoverButtonItem; |
| 6 | |
| 7 | |
| 8 | - (void)addItem:(NSString*)anItem { |
| 9 | [fSamples addObject:anItem]; |
| 10 | } |
| 11 | |
| 12 | - (void)initList { |
| 13 | fSamples = [[NSMutableArray alloc] init]; |
| 14 | } |
| 15 | |
| 16 | #pragma mark - |
| 17 | #pragma mark Rotation support |
| 18 | |
| 19 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
| 20 | return YES; |
| 21 | } |
| 22 | |
| 23 | #pragma mark - |
| 24 | #pragma mark View lifecycle |
| 25 | |
| 26 | |
| 27 | - (void)viewDidLoad { |
| 28 | [super viewDidLoad]; |
| 29 | self.contentSizeForViewInPopover = CGSizeMake(200, self.view.bounds.size.height); |
| 30 | } |
| 31 | |
| 32 | #pragma mark - |
| 33 | #pragma mark Table view data source |
| 34 | |
| 35 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { |
| 36 | // Return the number of sections. |
| 37 | return 1; |
| 38 | } |
| 39 | |
| 40 | |
| 41 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
| 42 | // Return the number of rows in the section. |
| 43 | return [fSamples count]; |
| 44 | } |
| 45 | |
| 46 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
| 47 | |
| 48 | static NSString *CellIdentifier = @"Cell"; |
| 49 | |
| 50 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
| 51 | if (cell == nil) { |
| 52 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
| 53 | reuseIdentifier:CellIdentifier] autorelease]; |
| 54 | } |
| 55 | |
| 56 | cell.textLabel.text = [fSamples objectAtIndex:indexPath.row]; |
| 57 | return cell; |
| 58 | } |
| 59 | |
| 60 | #pragma mark - |
| 61 | #pragma mark Memory management |
| 62 | |
| 63 | - (void)viewDidUnload { |
| 64 | [super viewDidUnload]; |
| 65 | self.popoverButtonItem = nil; |
| 66 | } |
| 67 | |
| 68 | - (void)dealloc { |
| 69 | [popoverController release]; |
| 70 | [popoverButtonItem release]; |
| 71 | [fSamples release]; |
| 72 | [super dealloc]; |
| 73 | } |
| 74 | @end |
| 75 | |