Advertisement
lenned

Code

May 30th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. XYZVIEWCONTROLLER.m:
  2.  
  3. //
  4. //  XYZViewController.h
  5. //  SADD
  6. //
  7. //  Created by Matthew on 5/30/13.
  8. //  Copyright (c) 2013 VSN. All rights reserved.
  9. //
  10.  
  11. #import <UIKit/UIKit.h>
  12.  
  13. @interface XYZViewController : UIViewController
  14.  
  15. -(IBAction)showEvents;
  16.  
  17. @end
  18.  
  19. XYZVIEWCONTROLLER.m
  20.  
  21. //
  22. //  XYZViewController.m
  23. //  SADD
  24. //
  25. //  Created by Matthew on 5/30/13.
  26. //  Copyright (c) 2013 VSN. All rights reserved.
  27. //
  28.  
  29. #import "XYZViewController.h"
  30. #import "EVENTSViewController.h"
  31.  
  32. @interface XYZViewController ()
  33.  
  34. @end
  35.  
  36. @implementation XYZViewController
  37.  
  38. - (void)viewDidLoad
  39. {
  40.     [super viewDidLoad];
  41.     // Do any additional setup after loading the view, typically from a nib.
  42. }
  43.  
  44. - (void)didReceiveMemoryWarning
  45. {
  46.     [super didReceiveMemoryWarning];
  47.     // Dispose of any resources that can be recreated.
  48. }
  49.  
  50. - (IBAction)showEvents
  51. {
  52.     EVENTSViewController *second = [[EVENTSViewController alloc] initWithNibName:@"EVENTSViewController" bundle:nil];
  53.     [self presentViewController:second animated:YES completion:nil];
  54.  
  55. }
  56.  
  57. @end
  58.  
  59.  
  60. EVENTSVIEWCONTROLLER.h:
  61.  
  62. //
  63. //  EVENTSViewController.h
  64. //  SADD
  65. //
  66. //  Created by Matthew on 5/30/13.
  67. //  Copyright (c) 2013 VSN. All rights reserved.
  68. //
  69.  
  70. #import <UIKit/UIKit.h>
  71. #import "SimpleTableCell.h"
  72.  
  73. @interface EVENTSViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
  74.  
  75. -(IBAction)back;
  76.  
  77. @end
  78.  
  79.  
  80. EVENTSVIEWCONTROLLER.m:
  81.  
  82.  
  83. //
  84. //  EVENTSViewController.m
  85. //  SADD
  86. //
  87. //  Created by Matthew on 5/30/13.
  88. //  Copyright (c) 2013 VSN. All rights reserved.
  89. //
  90.  
  91. #import "EVENTSViewController.h"
  92. #import "SimpleTableCell.h"
  93.  
  94. @interface EVENTSViewController ()
  95.  
  96. @end
  97.  
  98. @implementation EVENTSViewController
  99. {
  100.     NSArray *tableData;
  101.     NSArray *descriptionData;
  102. }
  103.  
  104. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  105. {
  106.     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  107.     if (self) {
  108.         // Custom initialization
  109.     }
  110.     return self;
  111. }
  112.  
  113. - (void)viewDidLoad
  114. {
  115.     [super viewDidLoad];
  116.     // Do any additional setup after loading the view.
  117.     tableData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full Breakfast", @"Hamburger", @"Ham and Egg Sandwich", @"Creme Brelee", @"White Chocolate Donut", @"Starbucks Coffee", @"Vegetable Curry", @"Instant Noodle with Egg", @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", @"Ham and Cheese Panini", nil];
  118.     descriptionData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full Breakfast", @"Hamburger", @"Ham and Egg Sandwich", @"Creme Brelee", @"White Chocolate Donut", @"Starbucks Coffee", @"Vegetable Curry", @"Instant Noodle with Egg", @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", @"Ham and Cheese Panini", nil];
  119. }
  120.  
  121. - (void)didReceiveMemoryWarning
  122. {
  123.     [super didReceiveMemoryWarning];
  124.     // Dispose of any resources that can be recreated.
  125. }
  126.  
  127. - (IBAction)back
  128. {
  129.     [self dismissViewControllerAnimated:YES completion:nil];
  130.    
  131. }
  132.  
  133. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  134. {
  135.     return [tableData count];
  136. }
  137.  
  138. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  139. {
  140.     static NSString *simpleTableIdentifier = @"SimpleTableCell";
  141.    
  142.     SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
  143.     if (cell == nil)
  144.     {
  145.         NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil];
  146.         cell = [nib objectAtIndex:0];
  147.     }
  148.    
  149.     cell.nameLabel.text = [tableData objectAtIndex:indexPath.row];
  150.     cell.descriptionLabel.text = [descriptionData objectAtIndex:indexPath.row];
  151.    
  152.     return cell;
  153. }
  154.  
  155. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  156. {
  157.     return 78;
  158. }
  159.  
  160. @end
  161.  
  162. SIMPLETABLECELL.h:
  163.  
  164.  
  165. //
  166. //  SimpleTableCell.h
  167. //  SADD
  168. //
  169. //  Created by Matthew on 5/30/13.
  170. //  Copyright (c) 2013 VSN. All rights reserved.
  171. //
  172.  
  173. #import <UIKit/UIKit.h>
  174.  
  175. @interface SimpleTableCell : UITableViewCell
  176.  
  177. @property (nonatomic, weak) IBOutlet UILabel *nameLabel;
  178. @property (nonatomic, weak) IBOutlet UILabel *descriptionLabel;
  179.  
  180. @end
  181.  
  182. SIMPLETABLECELL.m
  183.  
  184.  
  185. //
  186. //  SimpleTableCell.m
  187. //  SADD
  188. //
  189. //  Created by Matthew on 5/30/13.
  190. //  Copyright (c) 2013 VSN. All rights reserved.
  191. //
  192.  
  193. #import "SimpleTableCell.h"
  194.  
  195. @implementation SimpleTableCell
  196.  
  197. @synthesize nameLabel = _nameLabel;
  198. @synthesize descriptionLabel = _descriptionLabel;
  199.  
  200. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  201. {
  202.     self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  203.     if (self) {
  204.         // Initialization code
  205.     }
  206.     return self;
  207. }
  208.  
  209. - (void)setSelected:(BOOL)selected animated:(BOOL)animated
  210. {
  211.     [super setSelected:selected animated:animated];
  212.  
  213.     // Configure the view for the selected state
  214. }
  215.  
  216. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement