Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // RootViewController.m
- // Formelsamling
- //
- // Created by Casper Storm on 10/02/11.
- // Copyright 2011 __MyCompanyName__. All rights reserved.
- //
- #import "RootViewController.h"
- #import "DetailViewController.h"
- @implementation RootViewController
- @synthesize detailViewController;
- #pragma mark -
- #pragma mark View lifecycle
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.clearsSelectionOnViewWillAppear = NO;
- self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
- NSBundle *bundle = [NSBundle mainBundle];
- NSString *path = [bundle pathForResource:@"emner" ofType:@"plist"];
- emner = [[NSArray alloc] initWithContentsOfFile:path];
- // pathCon = [bundle pathForResource:@"algebra_test" ofType:@"html"];
- self.title = @"Emner";
- }
- /*
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- }
- */
- /*
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- }
- */
- /*
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- }
- */
- /*
- - (void)viewDidDisappear:(BOOL)animated {
- [super viewDidDisappear:animated];
- }
- */
- // Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- return YES;
- }
- #pragma mark -
- #pragma mark Table view data source
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView {
- // Return the number of sections.
- return 1;
- }
- // Sektioner:
- /*
- - (NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
- if (section == 0) return @"Test1";
- if (section == 1) return @"Test2";
- if (section == 2) return @"Test3";
- if (section == 3) return @"Test4";
- return @"Other";
- }
- */
- - (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
- // Return the number of rows in the section.
- return [emner count];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- static NSString *CellIdentifier = @"CellIdentifier";
- // Dequeue or create a cell of the appropriate type.
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
- cell.accessoryType = UITableViewCellAccessoryNone;
- // Selected Background View
- //cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"default_bg.png"]] autorelease];
- }
- /*
- // Sub text
- cell.detailTextLabel.text = @"Gennemgang af ....";
- */
- // Arrow in the right side
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- // Coloring
- cell.textLabel.textColor = [UIColor darkGrayColor];
- cell.detailTextLabel.textColor = [UIColor grayColor];
- // Configure the cell.
- //cell.textLabel.text = [NSString stringWithFormat:@"Row %d", indexPath.row];
- NSArray *temp = [emner objectAtIndex:indexPath.row];
- cell.textLabel.text = [temp objectAtIndex:0];
- return cell;
- }
- /*
- // Override to support conditional editing of the table view.
- - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
- // Return NO if you do not want the specified item to be editable.
- return YES;
- }
- */
- /*
- // Override to support editing the table view.
- - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
- if (editingStyle == UITableViewCellEditingStyleDelete) {
- // Delete the row from the data source
- [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
- }
- else if (editingStyle == UITableViewCellEditingStyleInsert) {
- // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
- }
- }
- */
- /*
- // Override to support rearranging the table view.
- - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
- }
- */
- /*
- // Override to support conditional rearranging of the table view.
- - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
- // Return NO if you do not want the item to be re-orderable.
- return YES;
- }
- */
- #pragma mark -
- #pragma mark Table view delegate
- - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- /*
- When a row is selected, set the detail view controller's detail item to the item associated with the selected row.
- */
- //detailViewController.detailItem = [NSString stringWithFormat:@"Row %d", indexPath.row];
- NSArray *temp = [emner objectAtIndex:indexPath.row];
- detailViewController.detailItem = [temp objectAtIndex:1];
- }
- #pragma mark -
- #pragma mark Memory management
- - (void)didReceiveMemoryWarning {
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
- // Relinquish ownership any cached data, images, etc. that aren't in use.
- }
- - (void)viewDidUnload {
- // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
- // For example: self.myOutlet = nil;
- }
- - (void)dealloc {
- [detailViewController release];
- [super dealloc];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement