blob: 3abece54e3b03743c35f0e1ffc1ebdb3f3094e6c (
plain)
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
|
//
// EditSubjectViewController.m
// FixMyStreet
//
// Created by Matthew on 01/10/2008.
// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
//
#import "EditSubjectViewController.h"
#import "EditingTableViewCell.h"
#import "FixMyStreetAppDelegate.h"
@implementation EditSubjectViewController
@synthesize cell;
/*
- (id)initWithStyle:(UITableViewStyle)style {
// Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
if (self = [super initWithStyle:style]) {
}
return self;
}
*/
-(void)setAll:(NSString*)a viewTitle:(NSString*)b placeholder:(NSString*)c keyboardType:(UIKeyboardType)d capitalisation:(UITextAutocapitalizationType)e {
cell = [[EditingTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"EditingCell"];
cell.textField.delegate = self;
cell.textField.placeholder = c;
self.title = b;
if (a) cell.textField.text = a;
cell.textField.keyboardType = d;
if (b == @"Edit name" || b == @"Edit email") {
cell.textField.autocorrectionType = UITextAutocorrectionTypeNo;
}
cell.textField.autocapitalizationType = e;
}
// Implement viewDidLoad to do additional setup after loading the view.
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.sectionHeaderHeight = 27.0;
self.tableView.sectionFooterHeight = 0.0;
// self.title = viewTitle;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:NO];
[cell.textField becomeFirstResponder];
}
- (void)viewWillAppear:(BOOL)animated {
//[super viewWillAppear:animated];
[cell.textField becomeFirstResponder];
}
/*
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
*/
- (void)viewWillDisappear:(BOOL)animated {
// On 2.0 this produces same effect as clicking Done, but not in 2.1?
[cell.textField resignFirstResponder];
}
/*
- (void)viewDidDisappear:(BOOL)animated {
}
*/
/*
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
*/
- (void)dealloc {
[cell release];
[super dealloc];
}
-(void)updateText:(NSString*)text {
FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
// This is yucky, but I can't think of a better way that wouldn't just waste time.
NSString* placeholder = cell.textField.placeholder;
if (placeholder == @"Summary") {
if (text.length) {
delegate.subject = text;
} else {
delegate.subject = nil;
}
} else if (placeholder == @"Your name") {
if (text.length) {
delegate.name = text;
} else {
delegate.name = nil;
}
} else if (placeholder == @"Your email") {
if (text.length) {
delegate.email = text;
} else {
delegate.email = nil;
}
} else if (placeholder == @"Your phone number") {
if (text.length) {
delegate.phone = text;
} else {
delegate.phone = nil;
}
}
[self.navigationController popViewControllerAnimated:YES];
}
-(BOOL)textFieldShouldReturn:(UITextField*)theTextField {
//if (theTextField == summaryTextField) {
[theTextField resignFirstResponder];
[self updateText:theTextField.text];
//}
return YES;
}
@end
|