iCuke 0.4.12 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/app/AlertsViewController.h +59 -0
- data/app/AlertsViewController.m +341 -0
- data/app/AppDelegate.h +60 -0
- data/app/AppDelegate.m +101 -0
- data/app/ButtonsViewController.h +80 -0
- data/app/ButtonsViewController.m +448 -0
- data/app/Constants.h +58 -0
- data/app/ControlsViewController.h +72 -0
- data/app/ControlsViewController.m +379 -0
- data/app/ImagesViewController.h +62 -0
- data/app/ImagesViewController.m +137 -0
- data/app/{iCuke/iCuke-Info.plist → Info.plist} +4 -4
- data/app/MainViewController.h +57 -0
- data/app/MainViewController.m +262 -0
- data/app/Picker/CustomPickerDataSource.h +55 -0
- data/app/Picker/CustomPickerDataSource.m +135 -0
- data/app/Picker/CustomView.h +62 -0
- data/app/Picker/CustomView.m +119 -0
- data/app/PickerViewController.h +88 -0
- data/app/PickerViewController.m +402 -0
- data/app/Prefix.pch +5 -0
- data/app/ReadMe.txt +82 -0
- data/app/SearchBarController.h +58 -0
- data/app/SearchBarController.m +105 -0
- data/app/SegmentViewController.h +54 -0
- data/app/SegmentViewController.m +195 -0
- data/app/TextFieldController.h +67 -0
- data/app/TextFieldController.m +342 -0
- data/app/TextViewController.h +57 -0
- data/app/TextViewController.m +164 -0
- data/app/ToolbarViewController.h +74 -0
- data/app/ToolbarViewController.m +303 -0
- data/app/TransitionViewController.h +64 -0
- data/app/TransitionViewController.m +178 -0
- data/app/UICatalog.xcodeproj/project.pbxproj +615 -0
- data/app/WebViewController.h +57 -0
- data/app/WebViewController.m +173 -0
- data/app/en.lproj/AlertsViewController.xib +144 -0
- data/app/en.lproj/ButtonsViewController.xib +147 -0
- data/app/en.lproj/ControlsViewController.xib +147 -0
- data/app/en.lproj/ImagesViewController.xib +264 -0
- data/app/en.lproj/Localizable.strings +41 -0
- data/app/en.lproj/MainWindow.xib +306 -0
- data/app/en.lproj/PickerViewController.xib +415 -0
- data/app/en.lproj/SearchBarController.xib +142 -0
- data/app/en.lproj/SegmentViewController.xib +143 -0
- data/app/en.lproj/TextFieldController.xib +167 -0
- data/app/en.lproj/TextViewController.xib +149 -0
- data/app/en.lproj/ToolbarViewController.xib +491 -0
- data/app/en.lproj/TransitionViewController.xib +255 -0
- data/app/en.lproj/WebViewController.xib +141 -0
- data/app/images/12-6AM.png +0 -0
- data/app/images/12-6PM.png +0 -0
- data/app/images/6-12AM.png +0 -0
- data/app/images/6-12PM.png +0 -0
- data/app/images/Default.png +0 -0
- data/app/images/Icon.png +0 -0
- data/app/images/UIButton_custom.png +0 -0
- data/app/images/blueButton.png +0 -0
- data/app/images/orangeslide.png +0 -0
- data/app/images/scene1.jpg +0 -0
- data/app/images/scene2.jpg +0 -0
- data/app/images/scene3.jpg +0 -0
- data/app/images/scene4.jpg +0 -0
- data/app/images/scene5.jpg +0 -0
- data/app/images/segment_check.png +0 -0
- data/app/images/segment_search.png +0 -0
- data/app/images/segment_tools.png +0 -0
- data/app/images/slider_ball.png +0 -0
- data/app/images/whiteButton.png +0 -0
- data/app/images/yellowslide.png +0 -0
- data/app/main.m +58 -0
- data/ext/iCuke/DefaultsResponse.m +0 -1
- data/ext/iCuke/EventResponse.m +9 -1
- data/ext/iCuke/Rakefile +1 -1
- data/ext/iCuke/Recorder.h +3 -1
- data/ext/iCuke/Recorder.m +10 -5
- data/ext/iCuke/RecorderResponse.h +1 -0
- data/ext/iCuke/RecorderResponse.m +10 -1
- data/ext/iCuke/Viewer.m +5 -6
- data/ext/iCuke/iCukeHTTPServer.m +1 -1
- data/ext/iCuke/iCukeServer.m +24 -7
- data/ext/iCuke/libicuke.dylib +0 -0
- data/features/uicatalog.feature +20 -0
- data/iCuke.gemspec +81 -24
- data/lib/icuke/com.apple.Accessibility.plist +0 -0
- data/lib/icuke/core_ext.rb +26 -0
- data/lib/icuke/cucumber.rb +20 -12
- data/lib/icuke/headless.rb +55 -0
- data/lib/icuke/simulator.rb +7 -129
- data/lib/icuke/xcode.rb +136 -0
- metadata +82 -25
- data/app/iCuke/Classes/FlipsideView.h +0 -13
- data/app/iCuke/Classes/FlipsideView.m +0 -32
- data/app/iCuke/Classes/FlipsideViewController.h +0 -25
- data/app/iCuke/Classes/FlipsideViewController.m +0 -54
- data/app/iCuke/Classes/MainView.h +0 -15
- data/app/iCuke/Classes/MainView.m +0 -32
- data/app/iCuke/Classes/MainViewController.h +0 -16
- data/app/iCuke/Classes/MainViewController.m +0 -86
- data/app/iCuke/Classes/iCukeAppDelegate.h +0 -20
- data/app/iCuke/Classes/iCukeAppDelegate.m +0 -33
- data/app/iCuke/FlipsideView.xib +0 -444
- data/app/iCuke/MainView.xib +0 -520
- data/app/iCuke/MainWindow.xib +0 -355
- data/app/iCuke/SniffingView.h +0 -20
- data/app/iCuke/SniffingView.m +0 -191
- data/app/iCuke/iCuke.xcodeproj/project.pbxproj +0 -313
- data/app/iCuke/iCuke_Prefix.pch +0 -14
- data/app/iCuke/main.m +0 -16
- data/features/icuke.feature +0 -17
- /data/app/{iCuke/.gitignore → .gitignore} +0 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/*
|
|
2
|
+
File: TextFieldController.m
|
|
3
|
+
Abstract: The view controller for hosting the UITextField features of this sample.
|
|
4
|
+
Version: 2.6
|
|
5
|
+
|
|
6
|
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
|
|
7
|
+
Inc. ("Apple") in consideration of your agreement to the following
|
|
8
|
+
terms, and your use, installation, modification or redistribution of
|
|
9
|
+
this Apple software constitutes acceptance of these terms. If you do
|
|
10
|
+
not agree with these terms, please do not use, install, modify or
|
|
11
|
+
redistribute this Apple software.
|
|
12
|
+
|
|
13
|
+
In consideration of your agreement to abide by the following terms, and
|
|
14
|
+
subject to these terms, Apple grants you a personal, non-exclusive
|
|
15
|
+
license, under Apple's copyrights in this original Apple software (the
|
|
16
|
+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
|
|
17
|
+
Software, with or without modifications, in source and/or binary forms;
|
|
18
|
+
provided that if you redistribute the Apple Software in its entirety and
|
|
19
|
+
without modifications, you must retain this notice and the following
|
|
20
|
+
text and disclaimers in all such redistributions of the Apple Software.
|
|
21
|
+
Neither the name, trademarks, service marks or logos of Apple Inc. may
|
|
22
|
+
be used to endorse or promote products derived from the Apple Software
|
|
23
|
+
without specific prior written permission from Apple. Except as
|
|
24
|
+
expressly stated in this notice, no other rights or licenses, express or
|
|
25
|
+
implied, are granted by Apple herein, including but not limited to any
|
|
26
|
+
patent rights that may be infringed by your derivative works or by other
|
|
27
|
+
works in which the Apple Software may be incorporated.
|
|
28
|
+
|
|
29
|
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
|
|
30
|
+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
|
|
31
|
+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
|
|
32
|
+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
|
|
33
|
+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
|
|
34
|
+
|
|
35
|
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
|
|
36
|
+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
37
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
38
|
+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
|
|
39
|
+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
|
|
40
|
+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
|
|
41
|
+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
|
|
42
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
43
|
+
|
|
44
|
+
Copyright (C) 2009 Apple Inc. All Rights Reserved.
|
|
45
|
+
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
#import "TextFieldController.h"
|
|
49
|
+
#import "Constants.h"
|
|
50
|
+
|
|
51
|
+
#define kTextFieldWidth 260.0
|
|
52
|
+
|
|
53
|
+
static NSString *kSectionTitleKey = @"sectionTitleKey";
|
|
54
|
+
static NSString *kSourceKey = @"sourceKey";
|
|
55
|
+
static NSString *kViewKey = @"viewKey";
|
|
56
|
+
|
|
57
|
+
const NSInteger kViewTag = 1;
|
|
58
|
+
|
|
59
|
+
@implementation TextFieldController
|
|
60
|
+
|
|
61
|
+
@synthesize textFieldNormal, textFieldRounded, textFieldSecure, textFieldLeftView, dataSourceArray;
|
|
62
|
+
|
|
63
|
+
- (void)dealloc
|
|
64
|
+
{
|
|
65
|
+
[textFieldNormal release];
|
|
66
|
+
[textFieldRounded release];
|
|
67
|
+
[textFieldSecure release];
|
|
68
|
+
[textFieldLeftView release];
|
|
69
|
+
|
|
70
|
+
[dataSourceArray release];
|
|
71
|
+
|
|
72
|
+
[super dealloc];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
- (void)viewDidLoad
|
|
76
|
+
{
|
|
77
|
+
[super viewDidLoad];
|
|
78
|
+
|
|
79
|
+
self.dataSourceArray = [NSArray arrayWithObjects:
|
|
80
|
+
[NSDictionary dictionaryWithObjectsAndKeys:
|
|
81
|
+
@"UITextField", kSectionTitleKey,
|
|
82
|
+
@"TextFieldController.m: textFieldNormal", kSourceKey,
|
|
83
|
+
self.textFieldNormal, kViewKey,
|
|
84
|
+
nil],
|
|
85
|
+
|
|
86
|
+
[NSDictionary dictionaryWithObjectsAndKeys:
|
|
87
|
+
@"UITextField Rounded", kSectionTitleKey,
|
|
88
|
+
@"TextFieldController.m: textFieldRounded", kSourceKey,
|
|
89
|
+
self.textFieldRounded, kViewKey,
|
|
90
|
+
nil],
|
|
91
|
+
|
|
92
|
+
[NSDictionary dictionaryWithObjectsAndKeys:
|
|
93
|
+
@"UITextField Secure", kSectionTitleKey,
|
|
94
|
+
@"TextFieldController.m: textFieldSecure", kSourceKey,
|
|
95
|
+
self.textFieldSecure, kViewKey,
|
|
96
|
+
nil],
|
|
97
|
+
|
|
98
|
+
[NSDictionary dictionaryWithObjectsAndKeys:
|
|
99
|
+
@"UITextField (with LeftView)", kSectionTitleKey,
|
|
100
|
+
@"TextFieldController.m: textFieldLeftView", kSourceKey,
|
|
101
|
+
self.textFieldLeftView, kViewKey,
|
|
102
|
+
nil],
|
|
103
|
+
nil];
|
|
104
|
+
|
|
105
|
+
self.title = NSLocalizedString(@"TextFieldTitle", @"");
|
|
106
|
+
|
|
107
|
+
// we aren't editing any fields yet, it will be in edit when the user touches an edit field
|
|
108
|
+
self.editing = NO;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// called after the view controller's view is released and set to nil.
|
|
112
|
+
// For example, a memory warning which causes the view to be purged. Not invoked as a result of -dealloc.
|
|
113
|
+
// So release any properties that are loaded in viewDidLoad or can be recreated lazily.
|
|
114
|
+
//
|
|
115
|
+
- (void)viewDidUnload
|
|
116
|
+
{
|
|
117
|
+
[super viewDidUnload];
|
|
118
|
+
|
|
119
|
+
// release the controls and set them nil in case they were ever created
|
|
120
|
+
// note: we can't use "self.xxx = nil" since they are read only properties
|
|
121
|
+
//
|
|
122
|
+
[textFieldNormal release];
|
|
123
|
+
textFieldNormal = nil;
|
|
124
|
+
[textFieldRounded release];
|
|
125
|
+
textFieldRounded = nil;
|
|
126
|
+
[textFieldSecure release];
|
|
127
|
+
textFieldSecure = nil;
|
|
128
|
+
[textFieldLeftView release];
|
|
129
|
+
textFieldLeftView = nil;
|
|
130
|
+
|
|
131
|
+
self.dataSourceArray = nil;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
#pragma mark -
|
|
136
|
+
#pragma mark UITableViewDataSource
|
|
137
|
+
|
|
138
|
+
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
|
139
|
+
{
|
|
140
|
+
return [self.dataSourceArray count];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
|
|
144
|
+
{
|
|
145
|
+
return [[self.dataSourceArray objectAtIndex: section] valueForKey:kSectionTitleKey];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
149
|
+
{
|
|
150
|
+
return 2;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// to determine specific row height for each cell, override this.
|
|
154
|
+
// In this example, each row is determined by its subviews that are embedded.
|
|
155
|
+
//
|
|
156
|
+
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
157
|
+
{
|
|
158
|
+
return ([indexPath row] == 0) ? 50.0 : 22.0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// to determine which UITableViewCell to be used on a given row.
|
|
162
|
+
//
|
|
163
|
+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
164
|
+
{
|
|
165
|
+
UITableViewCell *cell = nil;
|
|
166
|
+
NSUInteger row = [indexPath row];
|
|
167
|
+
if (row == 0)
|
|
168
|
+
{
|
|
169
|
+
static NSString *kCellTextField_ID = @"CellTextField_ID";
|
|
170
|
+
cell = [tableView dequeueReusableCellWithIdentifier:kCellTextField_ID];
|
|
171
|
+
if (cell == nil)
|
|
172
|
+
{
|
|
173
|
+
// a new cell needs to be created
|
|
174
|
+
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellTextField_ID] autorelease];
|
|
175
|
+
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
176
|
+
}
|
|
177
|
+
else
|
|
178
|
+
{
|
|
179
|
+
// a cell is being recycled, remove the old edit field (if it contains one of our tagged edit fields)
|
|
180
|
+
UIView *viewToCheck = nil;
|
|
181
|
+
viewToCheck = [cell.contentView viewWithTag:kViewTag];
|
|
182
|
+
if (!viewToCheck)
|
|
183
|
+
[viewToCheck removeFromSuperview];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
UITextField *textField = [[self.dataSourceArray objectAtIndex: indexPath.section] valueForKey:kViewKey];
|
|
187
|
+
[cell.contentView addSubview:textField];
|
|
188
|
+
}
|
|
189
|
+
else /* (row == 1) */
|
|
190
|
+
{
|
|
191
|
+
static NSString *kSourceCell_ID = @"SourceCell_ID";
|
|
192
|
+
cell = [tableView dequeueReusableCellWithIdentifier:kSourceCell_ID];
|
|
193
|
+
if (cell == nil)
|
|
194
|
+
{
|
|
195
|
+
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kSourceCell_ID] autorelease];
|
|
196
|
+
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
197
|
+
|
|
198
|
+
cell.textLabel.textAlignment = UITextAlignmentCenter;
|
|
199
|
+
cell.textLabel.textColor = [UIColor grayColor];
|
|
200
|
+
cell.textLabel.highlightedTextColor = [UIColor blackColor];
|
|
201
|
+
cell.textLabel.font = [UIFont systemFontOfSize:12];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
cell.textLabel.text = [[self.dataSourceArray objectAtIndex: indexPath.section] valueForKey:kSourceKey];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return cell;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
#pragma mark -
|
|
212
|
+
#pragma mark UITextFieldDelegate
|
|
213
|
+
|
|
214
|
+
- (BOOL)textFieldShouldReturn:(UITextField *)textField
|
|
215
|
+
{
|
|
216
|
+
// the user pressed the "Done" button, so dismiss the keyboard
|
|
217
|
+
[textField resignFirstResponder];
|
|
218
|
+
return YES;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
#pragma mark -
|
|
223
|
+
#pragma mark Text Fields
|
|
224
|
+
|
|
225
|
+
- (UITextField *)textFieldNormal
|
|
226
|
+
{
|
|
227
|
+
if (textFieldNormal == nil)
|
|
228
|
+
{
|
|
229
|
+
CGRect frame = CGRectMake(kLeftMargin, 8.0, kTextFieldWidth, kTextFieldHeight);
|
|
230
|
+
textFieldNormal = [[UITextField alloc] initWithFrame:frame];
|
|
231
|
+
|
|
232
|
+
textFieldNormal.borderStyle = UITextBorderStyleBezel;
|
|
233
|
+
textFieldNormal.textColor = [UIColor blackColor];
|
|
234
|
+
textFieldNormal.font = [UIFont systemFontOfSize:17.0];
|
|
235
|
+
textFieldNormal.placeholder = @"<enter text>";
|
|
236
|
+
textFieldNormal.backgroundColor = [UIColor whiteColor];
|
|
237
|
+
textFieldNormal.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support
|
|
238
|
+
|
|
239
|
+
textFieldNormal.keyboardType = UIKeyboardTypeDefault; // use the default type input method (entire keyboard)
|
|
240
|
+
textFieldNormal.returnKeyType = UIReturnKeyDone;
|
|
241
|
+
|
|
242
|
+
textFieldNormal.clearButtonMode = UITextFieldViewModeWhileEditing; // has a clear 'x' button to the right
|
|
243
|
+
|
|
244
|
+
textFieldNormal.tag = kViewTag; // tag this control so we can remove it later for recycled cells
|
|
245
|
+
|
|
246
|
+
textFieldNormal.delegate = self; // let us be the delegate so we know when the keyboard's "Done" button is pressed
|
|
247
|
+
|
|
248
|
+
// Add an accessibility label that describes what the text field is for.
|
|
249
|
+
[textFieldNormal setAccessibilityLabel:NSLocalizedString(@"NormalTextField", @"")];
|
|
250
|
+
}
|
|
251
|
+
return textFieldNormal;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
- (UITextField *)textFieldRounded
|
|
255
|
+
{
|
|
256
|
+
if (textFieldRounded == nil)
|
|
257
|
+
{
|
|
258
|
+
CGRect frame = CGRectMake(kLeftMargin, 8.0, kTextFieldWidth, kTextFieldHeight);
|
|
259
|
+
textFieldRounded = [[UITextField alloc] initWithFrame:frame];
|
|
260
|
+
|
|
261
|
+
textFieldRounded.borderStyle = UITextBorderStyleRoundedRect;
|
|
262
|
+
textFieldRounded.textColor = [UIColor blackColor];
|
|
263
|
+
textFieldRounded.font = [UIFont systemFontOfSize:17.0];
|
|
264
|
+
textFieldRounded.placeholder = @"<enter text>";
|
|
265
|
+
textFieldRounded.backgroundColor = [UIColor whiteColor];
|
|
266
|
+
textFieldRounded.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support
|
|
267
|
+
|
|
268
|
+
textFieldRounded.keyboardType = UIKeyboardTypeDefault;
|
|
269
|
+
textFieldRounded.returnKeyType = UIReturnKeyDone;
|
|
270
|
+
|
|
271
|
+
textFieldRounded.clearButtonMode = UITextFieldViewModeWhileEditing; // has a clear 'x' button to the right
|
|
272
|
+
|
|
273
|
+
textFieldRounded.tag = kViewTag; // tag this control so we can remove it later for recycled cells
|
|
274
|
+
|
|
275
|
+
textFieldRounded.delegate = self; // let us be the delegate so we know when the keyboard's "Done" button is pressed
|
|
276
|
+
|
|
277
|
+
// Add an accessibility label that describes what the text field is for.
|
|
278
|
+
[textFieldRounded setAccessibilityLabel:NSLocalizedString(@"RoundedTextField", @"")];
|
|
279
|
+
}
|
|
280
|
+
return textFieldRounded;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
- (UITextField *)textFieldSecure
|
|
284
|
+
{
|
|
285
|
+
if (textFieldSecure == nil)
|
|
286
|
+
{
|
|
287
|
+
CGRect frame = CGRectMake(kLeftMargin, 8.0, kTextFieldWidth, kTextFieldHeight);
|
|
288
|
+
textFieldSecure = [[UITextField alloc] initWithFrame:frame];
|
|
289
|
+
textFieldSecure.borderStyle = UITextBorderStyleBezel;
|
|
290
|
+
textFieldSecure.textColor = [UIColor blackColor];
|
|
291
|
+
textFieldSecure.font = [UIFont systemFontOfSize:17.0];
|
|
292
|
+
textFieldSecure.placeholder = @"<enter password>";
|
|
293
|
+
textFieldSecure.backgroundColor = [UIColor whiteColor];
|
|
294
|
+
|
|
295
|
+
textFieldSecure.keyboardType = UIKeyboardTypeDefault;
|
|
296
|
+
textFieldSecure.returnKeyType = UIReturnKeyDone;
|
|
297
|
+
textFieldSecure.secureTextEntry = YES; // make the text entry secure (bullets)
|
|
298
|
+
|
|
299
|
+
textFieldSecure.clearButtonMode = UITextFieldViewModeWhileEditing; // has a clear 'x' button to the right
|
|
300
|
+
|
|
301
|
+
textFieldSecure.tag = kViewTag; // tag this control so we can remove it later for recycled cells
|
|
302
|
+
|
|
303
|
+
textFieldSecure.delegate = self; // let us be the delegate so we know when the keyboard's "Done" button is pressed
|
|
304
|
+
|
|
305
|
+
// Add an accessibility label that describes what the text field is for.
|
|
306
|
+
[textFieldSecure setAccessibilityLabel:NSLocalizedString(@"SecureTextField", @"")];
|
|
307
|
+
}
|
|
308
|
+
return textFieldSecure;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
- (UITextField *)textFieldLeftView
|
|
312
|
+
{
|
|
313
|
+
if (textFieldLeftView == nil)
|
|
314
|
+
{
|
|
315
|
+
CGRect frame = CGRectMake(kLeftMargin, 8.0, kTextFieldWidth, kTextFieldHeight);
|
|
316
|
+
textFieldLeftView = [[UITextField alloc] initWithFrame:frame];
|
|
317
|
+
textFieldLeftView.borderStyle = UITextBorderStyleBezel;
|
|
318
|
+
textFieldLeftView.textColor = [UIColor blackColor];
|
|
319
|
+
textFieldLeftView.font = [UIFont systemFontOfSize:17.0];
|
|
320
|
+
textFieldLeftView.placeholder = @"<enter text>";
|
|
321
|
+
textFieldLeftView.backgroundColor = [UIColor whiteColor];
|
|
322
|
+
|
|
323
|
+
textFieldLeftView.keyboardType = UIKeyboardTypeDefault;
|
|
324
|
+
textFieldLeftView.returnKeyType = UIReturnKeyDone;
|
|
325
|
+
|
|
326
|
+
textFieldLeftView.clearButtonMode = UITextFieldViewModeWhileEditing; // has a clear 'x' button to the right
|
|
327
|
+
|
|
328
|
+
textFieldLeftView.tag = kViewTag; // tag this control so we can remove it later for recycled cells
|
|
329
|
+
|
|
330
|
+
// Add an accessibility label that describes the text field.
|
|
331
|
+
[textFieldLeftView setAccessibilityLabel:NSLocalizedString(@"CheckMarkIcon", @"")];
|
|
332
|
+
|
|
333
|
+
textFieldLeftView.leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"segment_check.png"]];
|
|
334
|
+
textFieldLeftView.leftViewMode = UITextFieldViewModeAlways;
|
|
335
|
+
|
|
336
|
+
textFieldLeftView.delegate = self; // let us be the delegate so we know when the keyboard's "Done" button is pressed
|
|
337
|
+
}
|
|
338
|
+
return textFieldLeftView;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
@end
|
|
342
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
File: TextViewController.h
|
|
3
|
+
Abstract: The view controller for hosting the UITextView features of this sample.
|
|
4
|
+
Version: 2.6
|
|
5
|
+
|
|
6
|
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
|
|
7
|
+
Inc. ("Apple") in consideration of your agreement to the following
|
|
8
|
+
terms, and your use, installation, modification or redistribution of
|
|
9
|
+
this Apple software constitutes acceptance of these terms. If you do
|
|
10
|
+
not agree with these terms, please do not use, install, modify or
|
|
11
|
+
redistribute this Apple software.
|
|
12
|
+
|
|
13
|
+
In consideration of your agreement to abide by the following terms, and
|
|
14
|
+
subject to these terms, Apple grants you a personal, non-exclusive
|
|
15
|
+
license, under Apple's copyrights in this original Apple software (the
|
|
16
|
+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
|
|
17
|
+
Software, with or without modifications, in source and/or binary forms;
|
|
18
|
+
provided that if you redistribute the Apple Software in its entirety and
|
|
19
|
+
without modifications, you must retain this notice and the following
|
|
20
|
+
text and disclaimers in all such redistributions of the Apple Software.
|
|
21
|
+
Neither the name, trademarks, service marks or logos of Apple Inc. may
|
|
22
|
+
be used to endorse or promote products derived from the Apple Software
|
|
23
|
+
without specific prior written permission from Apple. Except as
|
|
24
|
+
expressly stated in this notice, no other rights or licenses, express or
|
|
25
|
+
implied, are granted by Apple herein, including but not limited to any
|
|
26
|
+
patent rights that may be infringed by your derivative works or by other
|
|
27
|
+
works in which the Apple Software may be incorporated.
|
|
28
|
+
|
|
29
|
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
|
|
30
|
+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
|
|
31
|
+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
|
|
32
|
+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
|
|
33
|
+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
|
|
34
|
+
|
|
35
|
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
|
|
36
|
+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
37
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
38
|
+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
|
|
39
|
+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
|
|
40
|
+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
|
|
41
|
+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
|
|
42
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
43
|
+
|
|
44
|
+
Copyright (C) 2009 Apple Inc. All Rights Reserved.
|
|
45
|
+
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
#import <UIKit/UIKit.h>
|
|
49
|
+
|
|
50
|
+
@interface TextViewController : UIViewController <UITextViewDelegate>
|
|
51
|
+
{
|
|
52
|
+
UITextView *textView;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@property (nonatomic, retain) UITextView *textView;
|
|
56
|
+
|
|
57
|
+
@end
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/*
|
|
2
|
+
File: TextViewController.m
|
|
3
|
+
Abstract: The view controller for hosting the UITextView features of this sample.
|
|
4
|
+
Version: 2.6
|
|
5
|
+
|
|
6
|
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
|
|
7
|
+
Inc. ("Apple") in consideration of your agreement to the following
|
|
8
|
+
terms, and your use, installation, modification or redistribution of
|
|
9
|
+
this Apple software constitutes acceptance of these terms. If you do
|
|
10
|
+
not agree with these terms, please do not use, install, modify or
|
|
11
|
+
redistribute this Apple software.
|
|
12
|
+
|
|
13
|
+
In consideration of your agreement to abide by the following terms, and
|
|
14
|
+
subject to these terms, Apple grants you a personal, non-exclusive
|
|
15
|
+
license, under Apple's copyrights in this original Apple software (the
|
|
16
|
+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
|
|
17
|
+
Software, with or without modifications, in source and/or binary forms;
|
|
18
|
+
provided that if you redistribute the Apple Software in its entirety and
|
|
19
|
+
without modifications, you must retain this notice and the following
|
|
20
|
+
text and disclaimers in all such redistributions of the Apple Software.
|
|
21
|
+
Neither the name, trademarks, service marks or logos of Apple Inc. may
|
|
22
|
+
be used to endorse or promote products derived from the Apple Software
|
|
23
|
+
without specific prior written permission from Apple. Except as
|
|
24
|
+
expressly stated in this notice, no other rights or licenses, express or
|
|
25
|
+
implied, are granted by Apple herein, including but not limited to any
|
|
26
|
+
patent rights that may be infringed by your derivative works or by other
|
|
27
|
+
works in which the Apple Software may be incorporated.
|
|
28
|
+
|
|
29
|
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
|
|
30
|
+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
|
|
31
|
+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
|
|
32
|
+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
|
|
33
|
+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
|
|
34
|
+
|
|
35
|
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
|
|
36
|
+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
37
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
38
|
+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
|
|
39
|
+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
|
|
40
|
+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
|
|
41
|
+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
|
|
42
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
43
|
+
|
|
44
|
+
Copyright (C) 2009 Apple Inc. All Rights Reserved.
|
|
45
|
+
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
#import "TextViewController.h"
|
|
49
|
+
|
|
50
|
+
@implementation TextViewController
|
|
51
|
+
|
|
52
|
+
@synthesize textView;
|
|
53
|
+
|
|
54
|
+
- (void)dealloc
|
|
55
|
+
{
|
|
56
|
+
[textView release];
|
|
57
|
+
[super dealloc];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
- (void)setupTextView
|
|
61
|
+
{
|
|
62
|
+
self.textView = [[[UITextView alloc] initWithFrame:self.view.frame] autorelease];
|
|
63
|
+
self.textView.textColor = [UIColor blackColor];
|
|
64
|
+
self.textView.font = [UIFont fontWithName:@"Arial" size:18];
|
|
65
|
+
self.textView.delegate = self;
|
|
66
|
+
self.textView.backgroundColor = [UIColor whiteColor];
|
|
67
|
+
|
|
68
|
+
self.textView.text = @"Now is the time for all good developers to come to serve their country.\n\nNow is the time for all good developers to come to serve their country.";
|
|
69
|
+
self.textView.returnKeyType = UIReturnKeyDefault;
|
|
70
|
+
self.textView.keyboardType = UIKeyboardTypeDefault; // use the default type input method (entire keyboard)
|
|
71
|
+
self.textView.scrollEnabled = YES;
|
|
72
|
+
|
|
73
|
+
// this will cause automatic vertical resize when the table is resized
|
|
74
|
+
self.textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
|
|
75
|
+
|
|
76
|
+
// note: for UITextView, if you don't like autocompletion while typing use:
|
|
77
|
+
// myTextView.autocorrectionType = UITextAutocorrectionTypeNo;
|
|
78
|
+
|
|
79
|
+
[self.view addSubview: self.textView];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
- (void)viewDidLoad
|
|
83
|
+
{
|
|
84
|
+
[super viewDidLoad];
|
|
85
|
+
|
|
86
|
+
self.title = NSLocalizedString(@"TextViewTitle", @"");
|
|
87
|
+
[self setupTextView];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// called after the view controller's view is released and set to nil.
|
|
91
|
+
// For example, a memory warning which causes the view to be purged. Not invoked as a result of -dealloc.
|
|
92
|
+
// So release any properties that are loaded in viewDidLoad or can be recreated lazily.
|
|
93
|
+
//
|
|
94
|
+
- (void)viewDidUnload
|
|
95
|
+
{
|
|
96
|
+
[super viewDidUnload];
|
|
97
|
+
|
|
98
|
+
self.textView = nil;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
- (void)viewWillAppear:(BOOL)animated
|
|
102
|
+
{
|
|
103
|
+
// listen for keyboard hide/show notifications so we can properly adjust the table's height
|
|
104
|
+
[super viewWillAppear:animated];
|
|
105
|
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
|
|
106
|
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
- (void)viewDidDisappear:(BOOL)animated
|
|
110
|
+
{
|
|
111
|
+
[super viewDidDisappear:animated];
|
|
112
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
|
|
113
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
- (void)keyboardWillShow:(NSNotification *)aNotification
|
|
117
|
+
{
|
|
118
|
+
// the keyboard is showing so resize the table's height
|
|
119
|
+
CGRect keyboardRect = [[[aNotification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];
|
|
120
|
+
NSTimeInterval animationDuration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
|
|
121
|
+
CGRect frame = self.view.frame;
|
|
122
|
+
frame.size.height -= keyboardRect.size.height;
|
|
123
|
+
[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
|
|
124
|
+
[UIView setAnimationDuration:animationDuration];
|
|
125
|
+
self.view.frame = frame;
|
|
126
|
+
[UIView commitAnimations];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
- (void)keyboardWillHide:(NSNotification *)aNotification
|
|
130
|
+
{
|
|
131
|
+
// the keyboard is hiding reset the table's height
|
|
132
|
+
CGRect keyboardRect = [[[aNotification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];
|
|
133
|
+
NSTimeInterval animationDuration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
|
|
134
|
+
CGRect frame = self.view.frame;
|
|
135
|
+
frame.size.height += keyboardRect.size.height;
|
|
136
|
+
[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
|
|
137
|
+
[UIView setAnimationDuration:animationDuration];
|
|
138
|
+
self.view.frame = frame;
|
|
139
|
+
[UIView commitAnimations];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
#pragma mark -
|
|
144
|
+
#pragma mark UITextViewDelegate
|
|
145
|
+
|
|
146
|
+
- (void)textViewDidBeginEditing:(UITextView *)textView
|
|
147
|
+
{
|
|
148
|
+
// provide my own Save button to dismiss the keyboard
|
|
149
|
+
UIBarButtonItem* saveItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
|
|
150
|
+
target:self action:@selector(saveAction:)];
|
|
151
|
+
self.navigationItem.rightBarButtonItem = saveItem;
|
|
152
|
+
[saveItem release];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
- (void)saveAction:(id)sender
|
|
156
|
+
{
|
|
157
|
+
// finish typing text/dismiss the keyboard by removing it as the first responder
|
|
158
|
+
//
|
|
159
|
+
[self.textView resignFirstResponder];
|
|
160
|
+
self.navigationItem.rightBarButtonItem = nil; // this will remove the "save" button
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@end
|
|
164
|
+
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*
|
|
2
|
+
File: ToolbarViewController.h
|
|
3
|
+
Abstract: The view controller for hosting the UIToolbar and UIBarButtonItem features of this sample.
|
|
4
|
+
Version: 2.6
|
|
5
|
+
|
|
6
|
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
|
|
7
|
+
Inc. ("Apple") in consideration of your agreement to the following
|
|
8
|
+
terms, and your use, installation, modification or redistribution of
|
|
9
|
+
this Apple software constitutes acceptance of these terms. If you do
|
|
10
|
+
not agree with these terms, please do not use, install, modify or
|
|
11
|
+
redistribute this Apple software.
|
|
12
|
+
|
|
13
|
+
In consideration of your agreement to abide by the following terms, and
|
|
14
|
+
subject to these terms, Apple grants you a personal, non-exclusive
|
|
15
|
+
license, under Apple's copyrights in this original Apple software (the
|
|
16
|
+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
|
|
17
|
+
Software, with or without modifications, in source and/or binary forms;
|
|
18
|
+
provided that if you redistribute the Apple Software in its entirety and
|
|
19
|
+
without modifications, you must retain this notice and the following
|
|
20
|
+
text and disclaimers in all such redistributions of the Apple Software.
|
|
21
|
+
Neither the name, trademarks, service marks or logos of Apple Inc. may
|
|
22
|
+
be used to endorse or promote products derived from the Apple Software
|
|
23
|
+
without specific prior written permission from Apple. Except as
|
|
24
|
+
expressly stated in this notice, no other rights or licenses, express or
|
|
25
|
+
implied, are granted by Apple herein, including but not limited to any
|
|
26
|
+
patent rights that may be infringed by your derivative works or by other
|
|
27
|
+
works in which the Apple Software may be incorporated.
|
|
28
|
+
|
|
29
|
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
|
|
30
|
+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
|
|
31
|
+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
|
|
32
|
+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
|
|
33
|
+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
|
|
34
|
+
|
|
35
|
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
|
|
36
|
+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
37
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
38
|
+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
|
|
39
|
+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
|
|
40
|
+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
|
|
41
|
+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
|
|
42
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
43
|
+
|
|
44
|
+
Copyright (C) 2009 Apple Inc. All Rights Reserved.
|
|
45
|
+
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
#import <UIKit/UIKit.h>
|
|
49
|
+
|
|
50
|
+
@interface ToolbarViewController : UIViewController <UINavigationBarDelegate, UIPickerViewDelegate, UIPickerViewDataSource>
|
|
51
|
+
{
|
|
52
|
+
UISegmentedControl *barStyleSegControl;
|
|
53
|
+
UISwitch *tintSwitch;
|
|
54
|
+
UISegmentedControl *buttonItemStyleSegControl;
|
|
55
|
+
UIPickerView *systemButtonPicker;
|
|
56
|
+
|
|
57
|
+
UIToolbar *toolbar; // created programmatically, not in IB
|
|
58
|
+
NSArray *pickerViewArray;
|
|
59
|
+
UIBarButtonSystemItem currentSystemItem;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@property (nonatomic, retain) IBOutlet UISegmentedControl *barStyleSegControl;
|
|
63
|
+
@property (nonatomic, retain) IBOutlet UISwitch *tintSwitch;
|
|
64
|
+
@property (nonatomic, retain) IBOutlet UISegmentedControl *buttonItemStyleSegControl;
|
|
65
|
+
@property (nonatomic, retain) IBOutlet UIPickerView *systemButtonPicker;
|
|
66
|
+
|
|
67
|
+
@property (nonatomic, retain) UIToolbar *toolbar;
|
|
68
|
+
@property (nonatomic, retain) NSArray *pickerViewArray;
|
|
69
|
+
|
|
70
|
+
- (IBAction)toggleStyle:(id)sender;
|
|
71
|
+
- (IBAction)toggleBarStyle:(id)sender;
|
|
72
|
+
- (IBAction)toggleTintColor:(id)sender;
|
|
73
|
+
|
|
74
|
+
@end
|