Return to Snippet

Revision: 43453
at March 24, 2011 05:00 by rottendevice


Initial Code
//
//  HomeViewController.m
//  KaiserThrive
//
//  Created by John Dodge on 3/22/11.
//  Copyright 2011 Software Engineer. All rights reserved.
//

#import "HomeViewController.h"
#import "KaiserThriveAppDelegate.h"


@implementation HomeViewController

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
	CGRect gradientRect = CGRectMake(0.0f, 0.0f, 320.0f, 480.0f);
	whiteGrayGradient = [[UIImageView alloc] initWithFrame:gradientRect];
	[whiteGrayGradient setImage:[UIImage imageNamed:@"WhiteGrayGradientBG.png"]];
	whiteGrayGradient.opaque = YES; // explicitly opaque for performance
	
	CGRect headerRect = CGRectMake(0.0f, 20.0f, 320.0f, 111.0f);
	homeScreenHeader = [[UIImageView alloc] initWithFrame:headerRect];
	[homeScreenHeader setImage:[UIImage imageNamed:@"HomeScreen_Header.png"]];
	homeScreenHeader.opaque = YES; // explicitly opaque for performance
	
	gugdBtn = [UIButton buttonWithType:UIButtonTypeCustom];
	[gugdBtn addTarget:self action:@selector(homeBtnSelect:) forControlEvents:UIControlEventTouchDown];
	[gugdBtn setImage:[UIImage imageNamed:@"Thrive_iPhoneIcon.png"] forState:UIControlStateNormal];
	[gugdBtn setTitle:@"robot" forState:UIControlStateNormal];
	gugdBtn.frame = CGRectMake(58.0, 138.0, 89.0, 89.0);

	gugdLabel= [[UILabel alloc] initWithFrame:CGRectMake(48.0, 226.0, 110.0, 10.0)];
	gugdLabel.text = @"Get Up and Get Down!";
	gugdLabel.textColor = [UIColor darkGrayColor];
	gugdLabel.font = [UIFont systemFontOfSize:10];
	gugdLabel.textAlignment = UITextAlignmentCenter;
	gugdLabel.backgroundColor = [UIColor clearColor];
	
	assistBtn = [UIButton buttonWithType:UIButtonTypeCustom];
	[assistBtn addTarget:self action:@selector(homeBtnSelect:) forControlEvents:UIControlEventTouchDown];
	[assistBtn setImage:[UIImage imageNamed:@"PersonalAssistant_iPhoneIcon.png"] forState:UIControlStateNormal];
	[assistBtn setTitle:@"robot" forState:UIControlStateNormal];
	assistBtn.frame = CGRectMake(170.0, 138.0, 89.0, 89.0);
	
	assistLabel = [[UILabel alloc] initWithFrame:CGRectMake(160.0, 226.0, 115.0, 10.0)];
	assistLabel.text = @"Kaiser Personal Asst.";
	assistLabel.font = [UIFont systemFontOfSize:10];
	assistLabel.textColor = [UIColor darkGrayColor];
	assistLabel.textAlignment = UITextAlignmentCenter;
	assistLabel.backgroundColor = [UIColor clearColor];
	
	mapBtn = [UIButton buttonWithType:UIButtonTypeCustom];
	[mapBtn addTarget:self action:@selector(homeBtnSelect:) forControlEvents:UIControlEventTouchDown];
	[mapBtn setImage:[UIImage imageNamed:@"Places_iPhoneIcon.png"] forState:UIControlStateNormal];
	[mapBtn setTitle:@"robot" forState:UIControlStateNormal];
	mapBtn.frame = CGRectMake(58.0, 245.0, 89.0, 89.0);
	
	mapLabel = [[UILabel alloc] initWithFrame:CGRectMake(48.0, 334.0, 110.0, 10.0)];
	mapLabel.text = @"Locate Heathy Activities";
	mapLabel.font = [UIFont systemFontOfSize:10];
	mapLabel.textColor = [UIColor darkGrayColor];
	mapLabel.textAlignment = UITextAlignmentCenter;
	mapLabel.backgroundColor = [UIColor clearColor];
	
	lifestylesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
	[lifestylesBtn addTarget:self action:@selector(homeBtnSelect:) forControlEvents:UIControlEventTouchDown];
	[lifestylesBtn setImage:[UIImage imageNamed:@"HealthyLiving_iPhoneIcon.png"] forState:UIControlStateNormal];
	[lifestylesBtn setTitle:@"robot" forState:UIControlStateNormal];
	lifestylesBtn.frame = CGRectMake(170.0, 245, 89.0, 89.0);
	
	lifestylesLabel = [[UILabel alloc] initWithFrame:CGRectMake(160.0, 334.0, 115.0, 10.0)];
	lifestylesLabel.text = @"Heathy Lifestyles";
	lifestylesLabel.font = [UIFont systemFontOfSize:10];
	lifestylesLabel.textColor = [UIColor darkGrayColor];
	lifestylesLabel.textAlignment = UITextAlignmentCenter;
	lifestylesLabel.backgroundColor = [UIColor clearColor];
	
	followBtn = [UIButton buttonWithType:UIButtonTypeCustom];
	[followBtn addTarget:self action:@selector(homeBtnSelect:) forControlEvents:UIControlEventTouchDown];
	[followBtn setImage:[UIImage imageNamed:@"FollowUs_iPhoneIcon.png"] forState:UIControlStateNormal];
	[followBtn setTitle:@"robot" forState:UIControlStateNormal];
	followBtn.frame = CGRectMake(58.0, 348.0, 89.0, 89.0);
	
	followLabel = [[UILabel alloc] initWithFrame:CGRectMake(58.0, 436.0, 90.0, 10.0)];
	followLabel.text = @"Follow Us!";
	followLabel.minimumFontSize = 10;
	followLabel.font = [UIFont systemFontOfSize:10];
	followLabel.textColor = [UIColor darkGrayColor];
	followLabel.textAlignment = UITextAlignmentCenter;
	followLabel.backgroundColor = [UIColor clearColor];
	
	discountsBtn = [UIButton buttonWithType:UIButtonTypeCustom];
	[discountsBtn addTarget:self action:@selector(homeBtnSelect:) forControlEvents:UIControlEventTouchDown];
	[discountsBtn setImage:[UIImage imageNamed:@"MemberDiscount_iPhoneIcon.png"] forState:UIControlStateNormal];
	[discountsBtn setTitle:@"robot" forState:UIControlStateNormal];
	discountsBtn.frame = CGRectMake(170.0, 348.0, 89.0, 89.0);
	
	discountsLabel = [[UILabel alloc] initWithFrame:CGRectMake(160.0, 436.0, 115.0, 10.0)];
	discountsLabel.text = @"Member Discounts";
	discountsLabel.minimumFontSize = 10;
	discountsLabel.textColor = [UIColor darkGrayColor];
	discountsLabel.font = [UIFont systemFontOfSize:10];
	discountsLabel.textAlignment = UITextAlignmentCenter;
	discountsLabel.backgroundColor = [UIColor clearColor];
	
	[self.view addSubview:whiteGrayGradient];
	[self.view addSubview:homeScreenHeader];
	[self.view addSubview:gugdBtn];
	[self.view addSubview:assistBtn];
	[self.view addSubview:mapBtn];
	[self.view addSubview:lifestylesBtn];
	[self.view addSubview:followBtn];
	[self.view addSubview:discountsBtn];
	
	[self.view addSubview:gugdLabel];
	[self.view addSubview:assistLabel];
	[self.view addSubview:mapLabel];
	[self.view addSubview:lifestylesLabel];
	[self.view addSubview:followLabel];
	[self.view addSubview:discountsLabel];
}

- (void) homeBtnSelect:(UIButton *)button {
	if (button == gugdBtn) {
		[thriveViewController viewWillAppear:YES];
		//[yellowViewController viewWillDisappear:YES];
		
		[self.view removeFromSuperview];
		[appDelegate.window insertSubview:thriveViewController];
		//tabBarController *tbc = [[tabBarController alloc] initWithFrame: rect];
		//[self.view addSubview: tbc];
	}
	
}

Initial URL


Initial Description


Initial Title
Switching views

Initial Tags


Initial Language
Objective C