Created
October 10, 2012 09:16
-
-
Save beelsebob/3864297 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)viewDidLoad | |
| { | |
| [super viewDidLoad]; | |
| [self setTableView:[[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]]; | |
| [self setRegions:@[@[@"Bologna", @"Florence", @"Milan"]], @[@"Naples", @"Rome", @"Turin"]]]; | |
| [self setTitle:@"Region"]; | |
| } | |
| - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | |
| { | |
| return [[self regions][section] 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]; | |
| } | |
| [[cell textLabel] setText:[self regions][[indexPath section]][[indexPath row]]]; | |
| return cell; | |
| } | |
| - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath | |
| { | |
| CityController *cityController = [[CityController alloc] initWithNibName:@"CityController" bundle:nil]; | |
| [cityController setCity:[self regions][[indexPath section]][[indexPath row]]]; | |
| [[self navigationController] pushViewController:cityController animated:YES]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment