If you’ve used a Fitbit, Nike+ Running, RunKeeper or even Zombies Run! you’ll know how awesome fitness apps can be. An iPhone can be the ultimate fitness tool, so if you’re going to develop your spin on a fitness app, we’ve built the perfect template to give you the best head start. We’ve taken the best features from our favourite fitness apps and put them together with beautiful custom graphics to build an awesome fitness app template, just add a backend and turn it into your new activity app.
//
// NewActivityViewController.m
// RunSport
//
// Created by MyAppTemplates on 3/8/13.
// Copyright (c) 2013 MyAppTemplates. All rights reserved.
//
#import "NewActivityViewController.h"
#import "NewActivityItemCell.h"
#import "NewActivityOptionCell.h"
#import "ElementsViewController.h"
@interface NewActivityViewController ()
@end
@implementation NewActivityViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
+ (NewActivityViewController *) viewFromStoryboard
{
NewActivityViewController * controller = (NewActivityViewController *)[SuperViewController viewFromStoryBoard:@"NewActivityViewController"];
return controller;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self insertNavBarWithScreenName:STRDIC_NEWACTIVITY];
[btnBeginRun setTitle:[self.appDelegate getStringWithScreenName:STRDIC_NEWACTIVITY withStringID:STRID_NEWACTIVITY_BTNBEGIN]
forState:UIControlStateNormal];
inputButton = [[CustomSegmentedControl alloc] init];
[inputButton setSegmentWithCount:2
segmentsize:CGSizeMake( 98,60 )
dividerImage:nil
tag:9000
delegate:self];
[inputButton setFrame:CGRectMake( 70, 220, 196, 60 )];
[self.view addSubview:inputButton];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction) button_Click:(id)sender
{
;
}
#pragma mark --
#pragma mark -- UITableViewDelegate Method --
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 4;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
int cellRow = [indexPath row];
return (cellRow == 3) ? 64 : 46;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
int cellRow = [indexPath row];
UITableViewCell * cell = nil;
NSString *cellid = (cellRow == 3) ? @"NewActivityOptionCell" : @"NewActivityItemCell";
cell = [tableView dequeueReusableCellWithIdentifier:cellid];
if (cell == nil) {
if (cellRow == 3) {
cell = [[NewActivityOptionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];
}
else {
cell = [[NewActivityItemCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];
}
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
}
if (cellRow == 3) {
[(NewActivityOptionCell *)cell setCellContentWith:[self.appDelegate getStringWithScreenName:STRDIC_NEWACTIVITY withStringID:STRID_NEWACTIVITY_ROW3_L]
opt:YES];
}
else {
NSString * lText = @"";
NSString * rText = @"";
switch (cellRow) {
case 0:
lText = [self.appDelegate getStringWithScreenName:STRDIC_NEWACTIVITY withStringID:STRID_NEWACTIVITY_ROW0_L];
rText = [self.appDelegate getStringWithScreenName:STRDIC_NEWACTIVITY withStringID:STRID_NEWACTIVITY_ROW0_R];
break;
case 1:
lText = [self.appDelegate getStringWithScreenName:STRDIC_NEWACTIVITY withStringID:STRID_NEWACTIVITY_ROW1_L];
rText = [self.appDelegate getStringWithScreenName:STRDIC_NEWACTIVITY withStringID:STRID_NEWACTIVITY_ROW1_R];
break;
case 2:
lText = [self.appDelegate getStringWithScreenName:STRDIC_NEWACTIVITY withStringID:STRID_NEWACTIVITY_ROW2_L];
rText = [self.appDelegate getStringWithScreenName:STRDIC_NEWACTIVITY withStringID:STRID_NEWACTIVITY_ROW2_R];
break;
}
[(NewActivityItemCell *)cell setCellContentWith:lText rText:rText];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
#pragma mark --
- (UIButton*) buttonFor:(CustomSegmentedControl*)segmentedControl atIndex:(NSUInteger)segmentIndex
{
UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setFrame:CGRectMake( 0, 0, 98, 60 )];
if (segmentIndex == 0) {
[btn setBackgroundImage:[UIImage imageNamed:@"input-manual-selected.png"] forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImage imageNamed:@"input-manual-normal.png"] forState:UIControlStateSelected];
[btn setSelected:YES];
}
else {
[btn setBackgroundImage:[UIImage imageNamed:@"input-gps-selected.png"] forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImage imageNamed:@"input-gps-normal.png"] forState:UIControlStateSelected];
[btn setSelected:NO];
}
return btn;
}
- (void) touchUpInsideSegment:(CustomSegmentedControl *)segmentedControl index:(NSUInteger)segmentIndex
{
;
}
#pragma mark --
#pragma mark -- CustomNavBarViewDelegate --
- (void) didClickNavBarLeftButton
{
;
}
- (void) didClickNavBarRightButton
{
ElementsViewController * elementController = [ElementsViewController viewFromStoryboard];
[self.navigationController pushViewController:elementController animated:YES];
}
@end