2
// NewGameTableViewController.m
5
// Created by döme on 11.08.2009.
6
// Copyright 2009 __MyCompanyName__. All rights reserved.
9
#import "NewGameTableViewController.h"
10
#import "JigsawViewController.h"
13
@implementation NewGameTableViewController
16
- (id)initWithStyle:(UITableViewStyle)style {
17
// Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
18
if (self = [super initWithStyle:style]) {
28
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
29
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
34
- (void)viewWillAppear:(BOOL)animated {
35
[super viewWillAppear:animated];
39
- (void)viewDidAppear:(BOOL)animated {
40
[super viewDidAppear:animated];
44
- (void)viewWillDisappear:(BOOL)animated {
45
[super viewWillDisappear:animated];
49
- (void)viewDidDisappear:(BOOL)animated {
50
[super viewDidDisappear:animated];
55
// Override to allow orientations other than the default portrait orientation.
56
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
57
// Return YES for supported orientations
58
return (interfaceOrientation == UIInterfaceOrientationPortrait);
62
- (void)didReceiveMemoryWarning {
63
// Releases the view if it doesn't have a superview.
64
[super didReceiveMemoryWarning];
66
// Release any cached data, images, etc that aren't in use.
69
- (void)viewDidUnload {
70
// Release any retained subviews of the main view.
71
// e.g. self.myOutlet = nil;
77
[self.tableView setAllowsSelection: NO];
80
#pragma mark Table view methods
82
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
88
// Customize the number of rows in the table view.
89
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
101
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
103
switch (indexPath.section)
106
return imageCell.bounds.size.height;
109
switch (indexPath.row)
112
return sizeCell.bounds.size.height;
115
return rotationCell.bounds.size.height;
123
// Customize the appearance of table view cells.
124
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
126
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
128
switch (indexPath.section)
132
//[imageWell setImage: [UIImage imageWithData: [defaults objectForKey: NewJigsawImageKey]]];
137
switch (indexPath.row)
140
//[sizeSlider setValue: [defaults floatForKey: NewJigsawDensityKey]];
144
[rotationSwitch setOn: [defaults boolForKey: NewJigsawRotationEnabledKey]];
155
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
156
// Navigation logic may go here. Create and push another view controller.
157
// AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
158
// [self.navigationController pushViewController:anotherViewController];
159
// [anotherViewController release];
164
// Override to support conditional editing of the table view.
165
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
166
// Return NO if you do not want the specified item to be editable.
173
// Override to support editing the table view.
174
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
176
if (editingStyle == UITableViewCellEditingStyleDelete) {
177
// Delete the row from the data source
178
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
180
else if (editingStyle == UITableViewCellEditingStyleInsert) {
181
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
188
// Override to support rearranging the table view.
189
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
195
// Override to support conditional rearranging of the table view.
196
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
197
// Return NO if you do not want the item to be re-orderable.
202
- (IBAction) rotationChanged: (id) sender
204
[[NSUserDefaults standardUserDefaults] setBool: [sender isOn] forKey: NewJigsawRotationEnabledKey];
207
- (void) imageWasSelectedInWell: (ImageWell*) well
209
[[NSUserDefaults standardUserDefaults] setObject: UIImagePNGRepresentation([well image]) forKey: NewJigsawImageKey];