8 |
8 |
9 #import "AboutViewController.h" |
9 #import "AboutViewController.h" |
10 #import "CommodityFunctions.h" |
10 #import "CommodityFunctions.h" |
11 |
11 |
12 @implementation AboutViewController |
12 @implementation AboutViewController |
13 |
13 @synthesize tableView, segmentedControl, people; |
14 |
14 |
15 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
15 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
16 return rotationManager(interfaceOrientation); |
16 return rotationManager(interfaceOrientation); |
17 } |
17 } |
18 |
18 |
19 -(void) viewDidLoad { |
19 -(void) viewDidLoad { |
20 self.view.frame = CGRectMake(0, 0, 320, 480); |
20 self.tableView.backgroundView = nil; |
|
21 self.tableView.allowsSelection = NO; |
|
22 |
|
23 NSString *strPath = [NSString stringWithFormat:@"%@/Settings/credits.plist",[[NSBundle mainBundle] resourcePath]]; |
|
24 NSArray *array = [[NSArray alloc] initWithContentsOfFile:strPath]; |
|
25 self.people = array; |
|
26 [array release]; |
|
27 |
21 [super viewDidLoad]; |
28 [super viewDidLoad]; |
22 } |
|
23 |
|
24 -(void) didReceiveMemoryWarning { |
|
25 // Releases the view if it doesn't have a superview. |
|
26 [super didReceiveMemoryWarning]; |
|
27 |
|
28 // Release any cached data, images, etc that aren't in use. |
|
29 } |
|
30 |
|
31 -(void) viewDidUnload { |
|
32 [super viewDidUnload]; |
|
33 // Release any retained subviews of the main view. |
|
34 // e.g. self.myOutlet = nil; |
|
35 } |
|
36 |
|
37 -(void) dealloc { |
|
38 [super dealloc]; |
|
39 } |
29 } |
40 |
30 |
41 -(IBAction) buttonPressed:(id) sender { |
31 -(IBAction) buttonPressed:(id) sender { |
42 playSound(@"backSound"); |
32 playSound(@"backSound"); |
43 [[self parentViewController] dismissModalViewControllerAnimated:YES]; |
33 [[self parentViewController] dismissModalViewControllerAnimated:YES]; |
44 } |
34 } |
45 |
35 |
|
36 -(IBAction) segmentedControlChanged:(id) sender { |
|
37 playSound(@"clickSound"); |
|
38 [self.tableView setContentOffset:CGPointMake(0, 0) animated:NO]; |
|
39 [self.tableView reloadData]; |
|
40 } |
|
41 |
|
42 #pragma mark - |
|
43 #pragma mark Table view data source |
|
44 -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { |
|
45 return 1; |
|
46 } |
|
47 |
|
48 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
49 return [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] count]; |
|
50 } |
|
51 |
|
52 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
53 static NSString *CellIdentifier = @"Cell"; |
|
54 |
|
55 UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
|
56 if (cell == nil) |
|
57 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; |
|
58 |
|
59 // first all the names, then the title (which is offset 5) |
|
60 cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]]; |
|
61 cell.detailTextLabel.text = [[self.people objectAtIndex:(self.segmentedControl.selectedSegmentIndex + 5)] objectAtIndex:[indexPath row]]; |
|
62 |
|
63 return cell; |
|
64 } |
|
65 |
|
66 #pragma mark - |
|
67 #pragma mark Table view delegate |
|
68 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
69 // do nothing |
|
70 } |
|
71 |
|
72 #pragma mark - |
|
73 #pragma mark Memory Management |
|
74 -(void) didReceiveMemoryWarning { |
|
75 [super didReceiveMemoryWarning]; |
|
76 } |
|
77 |
|
78 -(void) viewDidUnload { |
|
79 self.tableView = nil; |
|
80 self.segmentedControl = nil; |
|
81 self.people = nil; |
|
82 [super viewDidUnload]; |
|
83 } |
|
84 |
|
85 -(void) dealloc { |
|
86 [tableView release]; |
|
87 [segmentedControl release]; |
|
88 [people release]; |
|
89 [super dealloc]; |
|
90 } |
|
91 |
46 @end |
92 @end |