Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  RootViewController.m
  3. //  Formelsamling
  4. //
  5. //  Created by Casper Storm on 10/02/11.
  6. //  Copyright 2011 __MyCompanyName__. All rights reserved.
  7. //
  8.  
  9. #import "RootViewController.h"
  10. #import "DetailViewController.h"
  11.  
  12.  
  13. @implementation RootViewController
  14.  
  15. @synthesize detailViewController;
  16.  
  17.  
  18. #pragma mark -
  19. #pragma mark View lifecycle
  20.  
  21. - (void)viewDidLoad {
  22.     [super viewDidLoad];
  23.     self.clearsSelectionOnViewWillAppear = NO;
  24.     self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
  25.    
  26.     NSBundle *bundle = [NSBundle mainBundle];
  27.     NSString *path = [bundle pathForResource:@"emner" ofType:@"plist"];
  28.     emner = [[NSArray alloc] initWithContentsOfFile:path];
  29.    
  30.    
  31. //  pathCon = [bundle pathForResource:@"algebra_test" ofType:@"html"];
  32.     self.title = @"Emner";
  33. }
  34.  
  35. /*
  36. - (void)viewWillAppear:(BOOL)animated {
  37.     [super viewWillAppear:animated];
  38. }
  39. */
  40. /*
  41. - (void)viewDidAppear:(BOOL)animated {
  42.     [super viewDidAppear:animated];
  43. }
  44. */
  45. /*
  46. - (void)viewWillDisappear:(BOOL)animated {
  47.     [super viewWillDisappear:animated];
  48. }
  49. */
  50. /*
  51. - (void)viewDidDisappear:(BOOL)animated {
  52.     [super viewDidDisappear:animated];
  53. }
  54. */
  55.  
  56. // Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
  57. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  58.     return YES;
  59. }
  60.  
  61.  
  62. #pragma mark -
  63. #pragma mark Table view data source
  64.  
  65. - (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView {
  66.     // Return the number of sections.
  67.     return 1;
  68. }
  69.  
  70. // Sektioner:
  71. /*
  72. - (NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
  73.    
  74.     if (section == 0) return @"Test1";
  75.     if (section == 1) return @"Test2";
  76.     if (section == 2) return @"Test3";
  77.     if (section == 3) return @"Test4";
  78.     return @"Other";
  79.    
  80. }
  81. */
  82.  
  83.  
  84. - (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
  85.     // Return the number of rows in the section.
  86.     return [emner count];
  87. }
  88.  
  89.  
  90. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  91.    
  92.     static NSString *CellIdentifier = @"CellIdentifier";
  93.    
  94.     // Dequeue or create a cell of the appropriate type.
  95.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  96.     if (cell == nil) {
  97.         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
  98.         cell.accessoryType = UITableViewCellAccessoryNone;
  99.  
  100.         // Selected Background View
  101.         //cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"default_bg.png"]] autorelease];
  102.     }
  103.     /*
  104.     // Sub text
  105.     cell.detailTextLabel.text = @"Gennemgang af ....";
  106.     */
  107.    
  108.     // Arrow in the right side
  109.     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  110.    
  111.     // Coloring
  112.     cell.textLabel.textColor = [UIColor darkGrayColor];
  113.     cell.detailTextLabel.textColor = [UIColor grayColor];
  114.    
  115.     // Configure the cell.
  116.     //cell.textLabel.text = [NSString stringWithFormat:@"Row %d", indexPath.row];
  117.     NSArray *temp = [emner objectAtIndex:indexPath.row];
  118.     cell.textLabel.text = [temp objectAtIndex:0];
  119.     return cell;
  120. }
  121.  
  122.  
  123. /*
  124. // Override to support conditional editing of the table view.
  125. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
  126.     // Return NO if you do not want the specified item to be editable.
  127.     return YES;
  128. }
  129. */
  130.  
  131.  
  132. /*
  133. // Override to support editing the table view.
  134. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  135.    
  136.     if (editingStyle == UITableViewCellEditingStyleDelete) {
  137.         // Delete the row from the data source
  138.         [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
  139.     }  
  140.     else if (editingStyle == UITableViewCellEditingStyleInsert) {
  141.         // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
  142.     }  
  143. }
  144. */
  145.  
  146.  
  147. /*
  148. // Override to support rearranging the table view.
  149. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
  150. }
  151. */
  152.  
  153.  
  154. /*
  155. // Override to support conditional rearranging of the table view.
  156. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
  157.     // Return NO if you do not want the item to be re-orderable.
  158.     return YES;
  159. }
  160. */
  161.  
  162. #pragma mark -
  163. #pragma mark Table view delegate
  164.  
  165. - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  166.    
  167.     /*
  168.      When a row is selected, set the detail view controller's detail item to the item associated with the selected row.
  169.      */
  170.     //detailViewController.detailItem = [NSString stringWithFormat:@"Row %d", indexPath.row];
  171.     NSArray *temp = [emner objectAtIndex:indexPath.row];
  172.     detailViewController.detailItem = [temp objectAtIndex:1];
  173. }
  174.  
  175.  
  176. #pragma mark -
  177. #pragma mark Memory management
  178.  
  179. - (void)didReceiveMemoryWarning {
  180.     // Releases the view if it doesn't have a superview.
  181.     [super didReceiveMemoryWarning];
  182.    
  183.     // Relinquish ownership any cached data, images, etc. that aren't in use.
  184. }
  185.  
  186. - (void)viewDidUnload {
  187.     // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
  188.     // For example: self.myOutlet = nil;
  189. }
  190.  
  191.  
  192. - (void)dealloc {
  193.     [detailViewController release];
  194.     [super dealloc];
  195. }
  196.  
  197.  
  198. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement