project_files/HedgewarsMobile/Classes/SupportViewController.m
branchios-develop
changeset 12872 00215a7ec5f5
parent 11549 893722a2a1f9
child 13166 ba5c794adae3
equal deleted inserted replaced
12871:2c06b1120749 12872:00215a7ec5f5
    21 #import "Appirater.h"
    21 #import "Appirater.h"
    22 
    22 
    23 @implementation SupportViewController
    23 @implementation SupportViewController
    24 @synthesize waysToSupport;
    24 @synthesize waysToSupport;
    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 #pragma mark -
    30 #pragma mark -
    31 #pragma mark View lifecycle
    31 #pragma mark View lifecycle
    32 -(void) viewDidLoad {
    32 - (void)viewDidLoad {
    33     [super viewDidLoad];
    33     [super viewDidLoad];
    34 
    34 
    35     NSArray *array = [[NSArray alloc] initWithObjects:
    35     NSArray *array = [[NSArray alloc] initWithObjects:
    36                       NSLocalizedString(@"Leave a positive review on iTunes!",@""),
    36                       NSLocalizedString(@"Leave a positive review on iTunes!",@""),
    37                       NSLocalizedString(@"Join us on Facebook",@""),
    37                       NSLocalizedString(@"Join us on Facebook",@""),
    38                       NSLocalizedString(@"Follow us on Twitter",@""),
    38                       NSLocalizedString(@"Follow us on Twitter",@""),
    39                       NSLocalizedString(@"Visit our website",@""),
    39                       NSLocalizedString(@"Visit our website",@""),
    40                       NSLocalizedString(@"Chat with the devs in IRC",@""),
    40                       NSLocalizedString(@"Chat with the devs in IRC",@""),
    41                       nil];
    41                       nil];
    42     self.waysToSupport = array;
    42     self.waysToSupport = array;
    43     [array release];
       
    44 
    43 
    45     self.navigationItem.title = @"♥";
    44     self.navigationItem.title = @"♥";
    46     self.tableView.rowHeight = 50;
    45     self.tableView.rowHeight = 50;
    47 }
    46 }
    48 
    47 
    65     NSInteger section = [indexPath section];
    64     NSInteger section = [indexPath section];
    66     NSString *imgName = @"";
    65     NSString *imgName = @"";
    67 
    66 
    68     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    67     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    69     if (cell == nil)
    68     if (cell == nil)
    70         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    69         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    71 
    70 
    72     NSString *rowString = [self.waysToSupport objectAtIndex:(row + section)];
    71     NSString *rowString = [self.waysToSupport objectAtIndex:(row + section)];
    73     cell.textLabel.text = rowString;
    72     cell.textLabel.text = rowString;
    74 
    73 
    75     if (section == 0) {
    74     if (section == 0) {
    98         cell.accessoryView = nil;
    97         cell.accessoryView = nil;
    99     }
    98     }
   100 
    99 
   101     NSString *imgString = [[NSString alloc] initWithFormat:@"%@/%@.png",[[NSBundle mainBundle] resourcePath],imgName];
   100     NSString *imgString = [[NSString alloc] initWithFormat:@"%@/%@.png",[[NSBundle mainBundle] resourcePath],imgName];
   102     UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgString];
   101     UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgString];
   103     [imgString release];
       
   104     cell.imageView.image = img;
   102     cell.imageView.image = img;
   105     if (section == 0) {
   103     if (section == 0) {
   106         UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
   104         UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
   107         cell.accessoryView = imgView;
   105         cell.accessoryView = imgView;
   108         [imgView release];
       
   109     }
   106     }
   110     [img release];
       
   111 
   107 
   112     return cell;
   108     return cell;
   113 }
   109 }
   114 
   110 
   115 #pragma mark -
   111 #pragma mark -
   116 #pragma mark Table view delegate
   112 #pragma mark Table view delegate
   117 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
   113 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
   118 {
   114 {
   119     if ([indexPath section] == 0)
   115     if ([indexPath section] == 0)
   120     {
   116     {
   121         [Appirater rateApp];
   117         [Appirater rateApp];
   122     }
   118     }
   143         }
   139         }
   144         [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
   140         [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
   145     }
   141     }
   146 }
   142 }
   147 
   143 
   148 -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section {
   144 -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
   149     if (section == 1) {
   145     if (section == 1) {
   150         UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 240)];
   146         UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 240)];
   151         footer.autoresizingMask = UIViewAutoresizingFlexibleWidth;
   147         footer.autoresizingMask = UIViewAutoresizingFlexibleWidth;
   152 
   148 
   153         UIImage *img = [[UIImage alloc] initWithContentsOfFile:@"surprise.png"];
   149         UIImage *img = [[UIImage alloc] initWithContentsOfFile:@"surprise.png"];
   154         UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
   150         UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
   155         [img release];
       
   156         imgView.center = CGPointMake(self.tableView.frame.size.width/2, 120);
   151         imgView.center = CGPointMake(self.tableView.frame.size.width/2, 120);
   157         imgView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
   152         imgView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
   158         [footer addSubview:imgView];
   153         [footer addSubview:imgView];
   159         [imgView release];
       
   160 
   154 
   161         UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 20)];
   155         UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 20)];
   162         label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
   156         label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
   163         label.textAlignment = NSTextAlignmentCenter;
   157         label.textAlignment = NSTextAlignmentCenter;
   164         label.text = NSLocalizedString(@" ♥ THANK YOU ♥ ", nil);
   158         label.text = NSLocalizedString(@" ♥ THANK YOU ♥ ", nil);
   165         label.backgroundColor = [UIColor clearColor];
   159         label.backgroundColor = [UIColor clearColor];
   166         label.center = CGPointMake(self.tableView.frame.size.width/2, 250);
   160         label.center = CGPointMake(self.tableView.frame.size.width/2, 250);
   167         [footer addSubview:label];
   161         [footer addSubview:label];
   168         [label release];
       
   169 
   162 
   170         return [footer autorelease];
   163         return footer;
   171     } else
   164     } else
   172         return nil;
   165         return nil;
   173 }
   166 }
   174 
   167 
   175 -(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
   168 -(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
   177     return (section == 1) ? 265 : 20;
   170     return (section == 1) ? 265 : 20;
   178 }
   171 }
   179 
   172 
   180 #pragma mark -
   173 #pragma mark -
   181 #pragma mark Memory management
   174 #pragma mark Memory management
       
   175 
   182 -(void)didReceiveMemoryWarning {
   176 -(void)didReceiveMemoryWarning {
   183     [super didReceiveMemoryWarning];
   177     [super didReceiveMemoryWarning];
   184 }
   178     MSG_MEMCLEAN();
   185 
       
   186 -(void) viewDidUnload {
       
   187     self.waysToSupport = nil;
       
   188     MSG_DIDUNLOAD();
       
   189     [super viewDidUnload];
       
   190 }
       
   191 
       
   192 -(void) dealloc {
       
   193     releaseAndNil(waysToSupport);
       
   194     [super dealloc];
       
   195 }
   179 }
   196 
   180 
   197 @end
   181 @end