Switching views


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  1. //
  2. // HomeViewController.m
  3. // KaiserThrive
  4. //
  5. // Created by John Dodge on 3/22/11.
  6. // Copyright 2011 Software Engineer. All rights reserved.
  7. //
  8.  
  9. #import "HomeViewController.h"
  10. #import "KaiserThriveAppDelegate.h"
  11.  
  12.  
  13. @implementation HomeViewController
  14.  
  15. /*
  16.  // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
  17. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  18.   if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
  19.   // Custom initialization
  20.   }
  21.   return self;
  22. }
  23. */
  24.  
  25.  
  26. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29.  
  30. CGRect gradientRect = CGRectMake(0.0f, 0.0f, 320.0f, 480.0f);
  31. whiteGrayGradient = [[UIImageView alloc] initWithFrame:gradientRect];
  32. [whiteGrayGradient setImage:[UIImage imageNamed:@"WhiteGrayGradientBG.png"]];
  33. whiteGrayGradient.opaque = YES; // explicitly opaque for performance
  34.  
  35. CGRect headerRect = CGRectMake(0.0f, 20.0f, 320.0f, 111.0f);
  36. homeScreenHeader = [[UIImageView alloc] initWithFrame:headerRect];
  37. [homeScreenHeader setImage:[UIImage imageNamed:@"HomeScreen_Header.png"]];
  38. homeScreenHeader.opaque = YES; // explicitly opaque for performance
  39.  
  40. gugdBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  41. [gugdBtn addTarget:self action:@selector(homeBtnSelect:) forControlEvents:UIControlEventTouchDown];
  42. [gugdBtn setImage:[UIImage imageNamed:@"Thrive_iPhoneIcon.png"] forState:UIControlStateNormal];
  43. [gugdBtn setTitle:@"robot" forState:UIControlStateNormal];
  44. gugdBtn.frame = CGRectMake(58.0, 138.0, 89.0, 89.0);
  45.  
  46. gugdLabel= [[UILabel alloc] initWithFrame:CGRectMake(48.0, 226.0, 110.0, 10.0)];
  47. gugdLabel.text = @"Get Up and Get Down!";
  48. gugdLabel.textColor = [UIColor darkGrayColor];
  49. gugdLabel.font = [UIFont systemFontOfSize:10];
  50. gugdLabel.textAlignment = UITextAlignmentCenter;
  51. gugdLabel.backgroundColor = [UIColor clearColor];
  52.  
  53. assistBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  54. [assistBtn addTarget:self action:@selector(homeBtnSelect:) forControlEvents:UIControlEventTouchDown];
  55. [assistBtn setImage:[UIImage imageNamed:@"PersonalAssistant_iPhoneIcon.png"] forState:UIControlStateNormal];
  56. [assistBtn setTitle:@"robot" forState:UIControlStateNormal];
  57. assistBtn.frame = CGRectMake(170.0, 138.0, 89.0, 89.0);
  58.  
  59. assistLabel = [[UILabel alloc] initWithFrame:CGRectMake(160.0, 226.0, 115.0, 10.0)];
  60. assistLabel.text = @"Kaiser Personal Asst.";
  61. assistLabel.font = [UIFont systemFontOfSize:10];
  62. assistLabel.textColor = [UIColor darkGrayColor];
  63. assistLabel.textAlignment = UITextAlignmentCenter;
  64. assistLabel.backgroundColor = [UIColor clearColor];
  65.  
  66. mapBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  67. [mapBtn addTarget:self action:@selector(homeBtnSelect:) forControlEvents:UIControlEventTouchDown];
  68. [mapBtn setImage:[UIImage imageNamed:@"Places_iPhoneIcon.png"] forState:UIControlStateNormal];
  69. [mapBtn setTitle:@"robot" forState:UIControlStateNormal];
  70. mapBtn.frame = CGRectMake(58.0, 245.0, 89.0, 89.0);
  71.  
  72. mapLabel = [[UILabel alloc] initWithFrame:CGRectMake(48.0, 334.0, 110.0, 10.0)];
  73. mapLabel.text = @"Locate Heathy Activities";
  74. mapLabel.font = [UIFont systemFontOfSize:10];
  75. mapLabel.textColor = [UIColor darkGrayColor];
  76. mapLabel.textAlignment = UITextAlignmentCenter;
  77. mapLabel.backgroundColor = [UIColor clearColor];
  78.  
  79. lifestylesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  80. [lifestylesBtn addTarget:self action:@selector(homeBtnSelect:) forControlEvents:UIControlEventTouchDown];
  81. [lifestylesBtn setImage:[UIImage imageNamed:@"HealthyLiving_iPhoneIcon.png"] forState:UIControlStateNormal];
  82. [lifestylesBtn setTitle:@"robot" forState:UIControlStateNormal];
  83. lifestylesBtn.frame = CGRectMake(170.0, 245, 89.0, 89.0);
  84.  
  85. lifestylesLabel = [[UILabel alloc] initWithFrame:CGRectMake(160.0, 334.0, 115.0, 10.0)];
  86. lifestylesLabel.text = @"Heathy Lifestyles";
  87. lifestylesLabel.font = [UIFont systemFontOfSize:10];
  88. lifestylesLabel.textColor = [UIColor darkGrayColor];
  89. lifestylesLabel.textAlignment = UITextAlignmentCenter;
  90. lifestylesLabel.backgroundColor = [UIColor clearColor];
  91.  
  92. followBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  93. [followBtn addTarget:self action:@selector(homeBtnSelect:) forControlEvents:UIControlEventTouchDown];
  94. [followBtn setImage:[UIImage imageNamed:@"FollowUs_iPhoneIcon.png"] forState:UIControlStateNormal];
  95. [followBtn setTitle:@"robot" forState:UIControlStateNormal];
  96. followBtn.frame = CGRectMake(58.0, 348.0, 89.0, 89.0);
  97.  
  98. followLabel = [[UILabel alloc] initWithFrame:CGRectMake(58.0, 436.0, 90.0, 10.0)];
  99. followLabel.text = @"Follow Us!";
  100. followLabel.minimumFontSize = 10;
  101. followLabel.font = [UIFont systemFontOfSize:10];
  102. followLabel.textColor = [UIColor darkGrayColor];
  103. followLabel.textAlignment = UITextAlignmentCenter;
  104. followLabel.backgroundColor = [UIColor clearColor];
  105.  
  106. discountsBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  107. [discountsBtn addTarget:self action:@selector(homeBtnSelect:) forControlEvents:UIControlEventTouchDown];
  108. [discountsBtn setImage:[UIImage imageNamed:@"MemberDiscount_iPhoneIcon.png"] forState:UIControlStateNormal];
  109. [discountsBtn setTitle:@"robot" forState:UIControlStateNormal];
  110. discountsBtn.frame = CGRectMake(170.0, 348.0, 89.0, 89.0);
  111.  
  112. discountsLabel = [[UILabel alloc] initWithFrame:CGRectMake(160.0, 436.0, 115.0, 10.0)];
  113. discountsLabel.text = @"Member Discounts";
  114. discountsLabel.minimumFontSize = 10;
  115. discountsLabel.textColor = [UIColor darkGrayColor];
  116. discountsLabel.font = [UIFont systemFontOfSize:10];
  117. discountsLabel.textAlignment = UITextAlignmentCenter;
  118. discountsLabel.backgroundColor = [UIColor clearColor];
  119.  
  120. [self.view addSubview:whiteGrayGradient];
  121. [self.view addSubview:homeScreenHeader];
  122. [self.view addSubview:gugdBtn];
  123. [self.view addSubview:assistBtn];
  124. [self.view addSubview:mapBtn];
  125. [self.view addSubview:lifestylesBtn];
  126. [self.view addSubview:followBtn];
  127. [self.view addSubview:discountsBtn];
  128.  
  129. [self.view addSubview:gugdLabel];
  130. [self.view addSubview:assistLabel];
  131. [self.view addSubview:mapLabel];
  132. [self.view addSubview:lifestylesLabel];
  133. [self.view addSubview:followLabel];
  134. [self.view addSubview:discountsLabel];
  135. }
  136.  
  137. - (void) homeBtnSelect:(UIButton *)button {
  138. if (button == gugdBtn) {
  139. [thriveViewController viewWillAppear:YES];
  140. //[yellowViewController viewWillDisappear:YES];
  141.  
  142. [self.view removeFromSuperview];
  143. [appDelegate.window insertSubview:thriveViewController];
  144. //tabBarController *tbc = [[tabBarController alloc] initWithFrame: rect];
  145. //[self.view addSubview: tbc];
  146. }
  147.  
  148. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.