project_files/HedgewarsMobile/Classes/AboutViewController.m
branchqmlfrontend
changeset 11408 b894922d58cc
parent 11308 92b023095153
child 11554 893722a2a1f9
equal deleted inserted replaced
11076:fcbdee9cdd74 11408:b894922d58cc
    25 
    25 
    26 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    26 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    27     return rotationManager(interfaceOrientation);
    27     return rotationManager(interfaceOrientation);
    28 }
    28 }
    29 
    29 
    30 -(void) viewDidLoad {
    30 -(void) viewDidLoad
       
    31 {
       
    32     [super viewDidLoad];
       
    33     
    31     [self.tableView setBackgroundColorForAnyTable:[UIColor clearColor]];
    34     [self.tableView setBackgroundColorForAnyTable:[UIColor clearColor]];
    32     self.tableView.allowsSelection = NO;
    35     self.tableView.allowsSelection = NO;
    33 
    36 
    34     NSArray *array = [[NSArray alloc] initWithContentsOfFile:CREDITS_FILE()];
    37     NSArray *array = [[NSArray alloc] initWithContentsOfFile:CREDITS_FILE()];
    35     self.people = array;
    38     self.people = array;
    46     background.frame = self.view.frame;
    49     background.frame = self.view.frame;
    47     background.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    50     background.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    48     [self.view insertSubview:background atIndex:0];
    51     [self.view insertSubview:background atIndex:0];
    49     [background release];
    52     [background release];
    50 
    53 
    51     [super viewDidLoad];
    54     [self localizeSegmentedControl];
    52 }
    55 }
    53 
    56 
    54 -(IBAction) buttonPressed:(id) sender {
    57 -(IBAction) buttonPressed:(id) sender {
    55     [[AudioManagerController mainManager] playBackSound];
    58     [[AudioManagerController mainManager] playBackSound];
    56     [[self parentViewController] dismissModalViewControllerAnimated:YES];
    59     [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
       
    60 }
       
    61 
       
    62 #pragma mark - Segmented Control
       
    63 
       
    64 - (void)localizeSegmentedControl
       
    65 {
       
    66     for (NSUInteger i = 0; i < self.segmentedControl.numberOfSegments; i++)
       
    67     {
       
    68         NSString *oldTitle = [self.segmentedControl titleForSegmentAtIndex:i];
       
    69         [self.segmentedControl setTitle:NSLocalizedStringFromTable(oldTitle, @"About", nil) forSegmentAtIndex:i];
       
    70     }
    57 }
    71 }
    58 
    72 
    59 -(IBAction) segmentedControlChanged:(id) sender {
    73 -(IBAction) segmentedControlChanged:(id) sender {
    60     [[AudioManagerController mainManager] playClickSound];
    74     [[AudioManagerController mainManager] playClickSound];
    61     [self.tableView setContentOffset:CGPointMake(0, 0) animated:NO];
    75     [self.tableView setContentOffset:CGPointMake(0, 0) animated:NO];
    81 
    95 
    82     // first all the names, then the title (which is offset 5)
    96     // first all the names, then the title (which is offset 5)
    83     cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]];
    97     cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]];
    84     cell.textLabel.adjustsFontSizeToFitWidth = YES;
    98     cell.textLabel.adjustsFontSizeToFitWidth = YES;
    85     cell.textLabel.minimumFontSize = 8;
    99     cell.textLabel.minimumFontSize = 8;
    86     cell.detailTextLabel.text = [[self.people objectAtIndex:(self.segmentedControl.selectedSegmentIndex + 5)] objectAtIndex:[indexPath row]];
   100     NSString *detailsKey = [[self.people objectAtIndex:(self.segmentedControl.selectedSegmentIndex + 5)] objectAtIndex:[indexPath row]];
       
   101     cell.detailTextLabel.text = NSLocalizedStringFromTable(detailsKey, @"About", nil);
    87 
   102 
    88     return cell;
   103     return cell;
    89 }
   104 }
    90 
   105 
    91 #pragma mark -
   106 #pragma mark -
   116     label.textAlignment = UITextAlignmentCenter;
   131     label.textAlignment = UITextAlignmentCenter;
   117     label.font = [UIFont systemFontOfSize:16];
   132     label.font = [UIFont systemFontOfSize:16];
   118     label.textColor = [UIColor lightGrayColor];
   133     label.textColor = [UIColor lightGrayColor];
   119     label.numberOfLines = 5;
   134     label.numberOfLines = 5;
   120     label.text = footerString;
   135     label.text = footerString;
       
   136     [footerString release];
   121 
   137 
   122     label.backgroundColor = [UIColor clearColor];
   138     label.backgroundColor = [UIColor clearColor];
   123     [footer addSubview:label];
   139     [footer addSubview:label];
   124     [label release];
   140     [label release];
   125     return [footer autorelease];
   141     return [footer autorelease];