-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSettingsViewController.m
More file actions
155 lines (101 loc) · 3.68 KB
/
Copy pathSettingsViewController.m
File metadata and controls
155 lines (101 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//
// SettingsViewController.m
// GPSTracker
//
// Created by Nic Jackson on 25/06/2010.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "SettingsViewController.h"
#import "GPSTrackerAppDelegate.h"
#import "PersistantStore.h"
@implementation SettingsViewController
@synthesize table;
/*
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
app = (GPSTrackerAppDelegate*)[UIApplication sharedApplication].delegate;
[super viewDidLoad];
}
#pragma mark -
#pragma mark TableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// 1 section
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCellStyle cellType = UITableViewCellStyleValue1;
if(indexPath.row == 1)
cellType = UITableViewCellStyleSubtitle;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:cellType reuseIdentifier:CellIdentifier] autorelease];
cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
switch (indexPath.row) {
case 0:
cell.textLabel.text = @"Auto upload photos with WIFI only:";
cell.detailTextLabel.text = (app.dataStore.autoUploadImagesWIFI) ? @"Yes" : @"No";
break;
case 1:
cell.textLabel.text = @"Google / Yahoo username:";
cell.detailTextLabel.text = app.dataStore.username;
break;
case 2:
cell.textLabel.text = @"Quick Follow:";
cell.detailTextLabel.text = (app.dataStore.useQuickFollow) ? @"Yes" : @"No";;
break;
}
return cell;
}
/**
Manage row selection: If a row is selected, create a new editing view controller to edit the property associated with the selected row.
*/
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
SettingsDetailController * detailController = [[SettingsDetailController alloc] initWithNibName:@"SettingsDetailController" bundle:nil];
switch (indexPath.row) {
case 0:
detailController.editingMode = kDetailViewEditingMode_UPLOADWIFI;
break;
case 1:
detailController.editingMode = kDetailViewEditingMode_USERNAME;
break;
case 2:
detailController.editingMode = kDetailViewEditingMode_QUICKFOLLOW;
break;
}
detailController.delegate = self;
[self presentModalViewController:detailController animated:YES];
[detailController release];
}
# pragma mark -
#pragma mark SettingsDetailController Delegate Methods
- (void)settingsDetailController:(SettingsDetailController *)controller didFinishWithSave:(BOOL)save {
[self dismissModalViewControllerAnimated:YES];
[table reloadData];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end