blob: 012ef66608c51017df20b93fd50201d7715113a7 (
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
|
//
// EditSubjectViewController.m
// FixMyStreet
//
// Created by Matthew on 01/10/2008.
// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
//
#import "EditSubjectViewController.h"
#import "SubjectTableViewCell.h"
#import "FixMyStreetAppDelegate.h"
@implementation EditSubjectViewController
/*
- (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;
}
*/
// Implement viewDidLoad to do additional setup after loading the view.
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Edit summary";
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
return subjectCell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:NO];
[subjectCell.textField becomeFirstResponder];
}
- (void)viewWillAppear:(BOOL)animated {
//[super viewWillAppear:animated];
if (!subjectCell) {
subjectCell = [[SubjectTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"SubjectCell"];
subjectCell.textField.delegate = self;
}
FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
if (delegate.subject) {
subjectCell.textField.text = delegate.subject;
}
[subjectCell.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?
[subjectCell.textField resignFirstResponder];
}
/*
- (void)viewDidDisappear:(BOOL)animated {
}
*/
/*
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
*/
- (void)dealloc {
[subjectCell release];
[super dealloc];
}
-(void)updateSummary:(NSString*)summary {
FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
if (summary.length) {
delegate.subject = summary;
} else {
delegate.subject = nil;
}
[self.navigationController popViewControllerAnimated:YES];
}
-(BOOL)textFieldShouldReturn:(UITextField*)theTextField {
//if (theTextField == summaryTextField) {
[theTextField resignFirstResponder];
[self updateSummary:theTextField.text];
//}
return YES;
}
@end
|