iCuke 0.4.12 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/Rakefile +3 -3
  2. data/VERSION +1 -1
  3. data/app/AlertsViewController.h +59 -0
  4. data/app/AlertsViewController.m +341 -0
  5. data/app/AppDelegate.h +60 -0
  6. data/app/AppDelegate.m +101 -0
  7. data/app/ButtonsViewController.h +80 -0
  8. data/app/ButtonsViewController.m +448 -0
  9. data/app/Constants.h +58 -0
  10. data/app/ControlsViewController.h +72 -0
  11. data/app/ControlsViewController.m +379 -0
  12. data/app/ImagesViewController.h +62 -0
  13. data/app/ImagesViewController.m +137 -0
  14. data/app/{iCuke/iCuke-Info.plist → Info.plist} +4 -4
  15. data/app/MainViewController.h +57 -0
  16. data/app/MainViewController.m +262 -0
  17. data/app/Picker/CustomPickerDataSource.h +55 -0
  18. data/app/Picker/CustomPickerDataSource.m +135 -0
  19. data/app/Picker/CustomView.h +62 -0
  20. data/app/Picker/CustomView.m +119 -0
  21. data/app/PickerViewController.h +88 -0
  22. data/app/PickerViewController.m +402 -0
  23. data/app/Prefix.pch +5 -0
  24. data/app/ReadMe.txt +82 -0
  25. data/app/SearchBarController.h +58 -0
  26. data/app/SearchBarController.m +105 -0
  27. data/app/SegmentViewController.h +54 -0
  28. data/app/SegmentViewController.m +195 -0
  29. data/app/TextFieldController.h +67 -0
  30. data/app/TextFieldController.m +342 -0
  31. data/app/TextViewController.h +57 -0
  32. data/app/TextViewController.m +164 -0
  33. data/app/ToolbarViewController.h +74 -0
  34. data/app/ToolbarViewController.m +303 -0
  35. data/app/TransitionViewController.h +64 -0
  36. data/app/TransitionViewController.m +178 -0
  37. data/app/UICatalog.xcodeproj/project.pbxproj +615 -0
  38. data/app/WebViewController.h +57 -0
  39. data/app/WebViewController.m +173 -0
  40. data/app/en.lproj/AlertsViewController.xib +144 -0
  41. data/app/en.lproj/ButtonsViewController.xib +147 -0
  42. data/app/en.lproj/ControlsViewController.xib +147 -0
  43. data/app/en.lproj/ImagesViewController.xib +264 -0
  44. data/app/en.lproj/Localizable.strings +41 -0
  45. data/app/en.lproj/MainWindow.xib +306 -0
  46. data/app/en.lproj/PickerViewController.xib +415 -0
  47. data/app/en.lproj/SearchBarController.xib +142 -0
  48. data/app/en.lproj/SegmentViewController.xib +143 -0
  49. data/app/en.lproj/TextFieldController.xib +167 -0
  50. data/app/en.lproj/TextViewController.xib +149 -0
  51. data/app/en.lproj/ToolbarViewController.xib +491 -0
  52. data/app/en.lproj/TransitionViewController.xib +255 -0
  53. data/app/en.lproj/WebViewController.xib +141 -0
  54. data/app/images/12-6AM.png +0 -0
  55. data/app/images/12-6PM.png +0 -0
  56. data/app/images/6-12AM.png +0 -0
  57. data/app/images/6-12PM.png +0 -0
  58. data/app/images/Default.png +0 -0
  59. data/app/images/Icon.png +0 -0
  60. data/app/images/UIButton_custom.png +0 -0
  61. data/app/images/blueButton.png +0 -0
  62. data/app/images/orangeslide.png +0 -0
  63. data/app/images/scene1.jpg +0 -0
  64. data/app/images/scene2.jpg +0 -0
  65. data/app/images/scene3.jpg +0 -0
  66. data/app/images/scene4.jpg +0 -0
  67. data/app/images/scene5.jpg +0 -0
  68. data/app/images/segment_check.png +0 -0
  69. data/app/images/segment_search.png +0 -0
  70. data/app/images/segment_tools.png +0 -0
  71. data/app/images/slider_ball.png +0 -0
  72. data/app/images/whiteButton.png +0 -0
  73. data/app/images/yellowslide.png +0 -0
  74. data/app/main.m +58 -0
  75. data/ext/iCuke/DefaultsResponse.m +0 -1
  76. data/ext/iCuke/EventResponse.m +9 -1
  77. data/ext/iCuke/Rakefile +1 -1
  78. data/ext/iCuke/Recorder.h +3 -1
  79. data/ext/iCuke/Recorder.m +10 -5
  80. data/ext/iCuke/RecorderResponse.h +1 -0
  81. data/ext/iCuke/RecorderResponse.m +10 -1
  82. data/ext/iCuke/Viewer.m +5 -6
  83. data/ext/iCuke/iCukeHTTPServer.m +1 -1
  84. data/ext/iCuke/iCukeServer.m +24 -7
  85. data/ext/iCuke/libicuke.dylib +0 -0
  86. data/features/uicatalog.feature +20 -0
  87. data/iCuke.gemspec +81 -24
  88. data/lib/icuke/com.apple.Accessibility.plist +0 -0
  89. data/lib/icuke/core_ext.rb +26 -0
  90. data/lib/icuke/cucumber.rb +20 -12
  91. data/lib/icuke/headless.rb +55 -0
  92. data/lib/icuke/simulator.rb +7 -129
  93. data/lib/icuke/xcode.rb +136 -0
  94. metadata +82 -25
  95. data/app/iCuke/Classes/FlipsideView.h +0 -13
  96. data/app/iCuke/Classes/FlipsideView.m +0 -32
  97. data/app/iCuke/Classes/FlipsideViewController.h +0 -25
  98. data/app/iCuke/Classes/FlipsideViewController.m +0 -54
  99. data/app/iCuke/Classes/MainView.h +0 -15
  100. data/app/iCuke/Classes/MainView.m +0 -32
  101. data/app/iCuke/Classes/MainViewController.h +0 -16
  102. data/app/iCuke/Classes/MainViewController.m +0 -86
  103. data/app/iCuke/Classes/iCukeAppDelegate.h +0 -20
  104. data/app/iCuke/Classes/iCukeAppDelegate.m +0 -33
  105. data/app/iCuke/FlipsideView.xib +0 -444
  106. data/app/iCuke/MainView.xib +0 -520
  107. data/app/iCuke/MainWindow.xib +0 -355
  108. data/app/iCuke/SniffingView.h +0 -20
  109. data/app/iCuke/SniffingView.m +0 -191
  110. data/app/iCuke/iCuke.xcodeproj/project.pbxproj +0 -313
  111. data/app/iCuke/iCuke_Prefix.pch +0 -14
  112. data/app/iCuke/main.m +0 -16
  113. data/features/icuke.feature +0 -17
  114. /data/app/{iCuke/.gitignore → .gitignore} +0 -0
@@ -0,0 +1,262 @@
1
+ /*
2
+ File: MainViewController.m
3
+ Abstract: The application's main view controller (front page).
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 "MainViewController.h"
49
+
50
+ #import "ButtonsViewController.h"
51
+ #import "ControlsViewController.h"
52
+ #import "TextFieldController.h"
53
+ #import "SearchBarController.h"
54
+ #import "TextViewController.h"
55
+ #import "SegmentViewController.h"
56
+ #import "ToolbarViewController.h"
57
+ #import "PickerViewController.h"
58
+ #import "ImagesViewController.h"
59
+ #import "WebViewController.h"
60
+ #import "AlertsViewController.h"
61
+ #import "TransitionViewController.h"
62
+
63
+ #import "Constants.h"
64
+
65
+ static NSString *kCellIdentifier = @"MyIdentifier";
66
+ static NSString *kTitleKey = @"title";
67
+ static NSString *kViewControllerKey = @"viewController";
68
+
69
+ @implementation MainViewController
70
+
71
+ @synthesize menuList;
72
+
73
+ - (void)viewDidLoad
74
+ {
75
+ [super viewDidLoad];
76
+
77
+ // construct the array of page descriptions we will use (each description is a dictionary)
78
+ //
79
+ self.menuList = [NSMutableArray array];
80
+
81
+ // for showing various UIButtons:
82
+ ButtonsViewController *buttonsViewController = [[ButtonsViewController alloc]
83
+ initWithNibName:@"ButtonsViewController" bundle:nil];
84
+ [self.menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
85
+ NSLocalizedString(@"ButtonsTitle", @""), kTitleKey,
86
+ buttonsViewController, kViewControllerKey,
87
+ nil]];
88
+ [buttonsViewController release];
89
+
90
+ // for showing various UIControls:
91
+ ControlsViewController *controlsViewController = [[ControlsViewController alloc]
92
+ initWithNibName:@"ControlsViewController" bundle:nil];
93
+ [self.menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
94
+ NSLocalizedString(@"ControlsTitle", @""), kTitleKey,
95
+ controlsViewController, kViewControllerKey,
96
+ nil]];
97
+ [controlsViewController release];
98
+
99
+ // for showing various UITextFields:
100
+ TextFieldController *textFieldViewController = [[TextFieldController alloc]
101
+ initWithNibName:@"TextFieldController" bundle:nil];
102
+ [self.menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
103
+ NSLocalizedString(@"TextFieldTitle", @""), kTitleKey,
104
+ textFieldViewController, kViewControllerKey,
105
+ nil]];
106
+ [textFieldViewController release];
107
+
108
+ // for UISearchBar:
109
+ SearchBarController *searchBarController = [[SearchBarController alloc]
110
+ initWithNibName:@"SearchBarController" bundle:nil];
111
+ [self.menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
112
+ NSLocalizedString(@"SearchBarTitle", @""), kTitleKey,
113
+ searchBarController, kViewControllerKey,
114
+ nil]];
115
+ [searchBarController release];
116
+
117
+ // for showing UITextView:
118
+ TextViewController *textViewController = [[TextViewController alloc]
119
+ initWithNibName:@"TextViewController" bundle:nil];
120
+ [self.menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
121
+ NSLocalizedString(@"TextViewTitle", @""), kTitleKey,
122
+ textViewController, kViewControllerKey,
123
+ nil]];
124
+ [textViewController release];
125
+
126
+ // for showing various UIPickers:
127
+ PickerViewController *pickerViewController = [[PickerViewController alloc]
128
+ initWithNibName:@"PickerViewController" bundle:nil];
129
+ [self.menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
130
+ NSLocalizedString(@"PickerTitle", @""), kTitleKey,
131
+ pickerViewController, kViewControllerKey,
132
+ nil]];
133
+ [pickerViewController release];
134
+
135
+ // for showing UIImageView:
136
+ ImagesViewController *imagesViewController = [[ImagesViewController alloc]
137
+ initWithNibName:@"ImagesViewController" bundle:nil];
138
+ [self.menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
139
+ NSLocalizedString(@"ImagesTitle", @""), kTitleKey,
140
+ imagesViewController, kViewControllerKey,
141
+ nil]];
142
+ [imagesViewController release];
143
+
144
+ // for showing UIWebView:
145
+ WebViewController *webViewController = [[WebViewController alloc]
146
+ initWithNibName:@"WebViewController" bundle:nil];
147
+ [self.menuList addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:
148
+ NSLocalizedString(@"WebTitle", @""), kTitleKey,
149
+ webViewController, kViewControllerKey,
150
+ nil]];
151
+ [webViewController release];
152
+
153
+ // for showing various UISegmentedControls:
154
+ SegmentViewController *segmentViewController = [[SegmentViewController alloc]
155
+ initWithNibName:@"SegmentViewController" bundle:nil];
156
+ [self.menuList addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:
157
+ NSLocalizedString(@"SegmentTitle", @""), kTitleKey,
158
+ segmentViewController, kViewControllerKey,
159
+ nil]];
160
+ [segmentViewController release];
161
+
162
+ // for showing various UIBarButtonItem items inside a UIToolbar:
163
+ ToolbarViewController *toolbarViewController = [[ToolbarViewController alloc]
164
+ initWithNibName:@"ToolbarViewController" bundle:nil];
165
+ [self.menuList addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:
166
+ NSLocalizedString(@"ToolbarTitle", @""), kTitleKey,
167
+ toolbarViewController, kViewControllerKey,
168
+ nil]];
169
+ [toolbarViewController release];
170
+
171
+ // for showing various UIActionSheets and UIAlertViews:
172
+ AlertsViewController *alertsViewController = [[AlertsViewController alloc]
173
+ initWithNibName:@"AlertsViewController" bundle:nil];
174
+ [self.menuList addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:
175
+ NSLocalizedString(@"AlertTitle", @""), kTitleKey,
176
+ alertsViewController, kViewControllerKey,
177
+ nil]];
178
+ [alertsViewController release];
179
+
180
+ // for showing how to a use flip animation transition between two UIViews:
181
+ TransitionsViewController *transitionsViewController = [[TransitionsViewController alloc]
182
+ initWithNibName:@"TransitionViewController" bundle:nil];
183
+ [self.menuList addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:
184
+ NSLocalizedString(@"TransitionsTitle", @""), kTitleKey,
185
+ transitionsViewController, kViewControllerKey,
186
+ nil]];
187
+ [transitionsViewController release];
188
+
189
+ // create a custom navigation bar button and set it to always say "Back"
190
+ UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] init];
191
+ temporaryBarButtonItem.title = @"Back";
192
+ self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
193
+ [temporaryBarButtonItem release];
194
+ }
195
+
196
+ // called after the view controller's view is released and set to nil.
197
+ // For example, a memory warning which causes the view to be purged. Not invoked as a result of -dealloc.
198
+ // So release any properties that are loaded in viewDidLoad or can be recreated lazily.
199
+ //
200
+ - (void)viewDidUnload
201
+ {
202
+ [super viewDidUnload];
203
+
204
+ self.menuList = nil;
205
+ }
206
+
207
+ - (void)dealloc
208
+ {
209
+ [menuList release];
210
+ [super dealloc];
211
+ }
212
+
213
+
214
+ #pragma mark -
215
+ #pragma mark UIViewController delegate
216
+
217
+ - (void)viewWillAppear:(BOOL)animated
218
+ {
219
+ // this UIViewController is about to re-appear, make sure we remove the current selection in our table view
220
+ NSIndexPath *tableSelection = [self.tableView indexPathForSelectedRow];
221
+ [self.tableView deselectRowAtIndexPath:tableSelection animated:NO];
222
+ }
223
+
224
+
225
+ #pragma mark -
226
+ #pragma mark UITableViewDelegate
227
+
228
+ // the table's selection has changed, switch to that item's UIViewController
229
+ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
230
+ {
231
+ UIViewController *targetViewController = [[self.menuList objectAtIndex: indexPath.row] objectForKey:kViewControllerKey];
232
+ [[self navigationController] pushViewController:targetViewController animated:YES];
233
+ }
234
+
235
+
236
+ #pragma mark -
237
+ #pragma mark UITableViewDataSource
238
+
239
+ // tell our table how many rows it will have, in our case the size of our menuList
240
+ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
241
+ {
242
+ return [self.menuList count];
243
+ }
244
+
245
+ // tell our table what kind of cell to use and its title for the given row
246
+ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
247
+ {
248
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
249
+ if (cell == nil)
250
+ {
251
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellIdentifier] autorelease];
252
+ cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
253
+ }
254
+
255
+ cell.textLabel.text = [[self.menuList objectAtIndex:indexPath.row] objectForKey:kTitleKey];
256
+
257
+ return cell;
258
+ }
259
+
260
+ @end
261
+
262
+
@@ -0,0 +1,55 @@
1
+ /*
2
+ File: CustomPickerDataSource.h
3
+ Abstract: The data source for the Custom Picker that displays text and images.
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
+ @interface CustomPickerDataSource : NSObject <UIPickerViewDataSource, UIPickerViewDelegate>
49
+ {
50
+ NSArray *customPickerArray;
51
+ }
52
+
53
+ @property (nonatomic, retain) NSArray *customPickerArray;
54
+
55
+ @end
@@ -0,0 +1,135 @@
1
+ /*
2
+ File: CustomPickerDataSource.m
3
+ Abstract: The data source for the Custom Picker that displays text and images.
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 "CustomPickerDataSource.h"
49
+ #import "CustomView.h"
50
+
51
+ @implementation CustomPickerDataSource
52
+
53
+ @synthesize customPickerArray;
54
+
55
+ - (id)init
56
+ {
57
+ // use predetermined frame size
58
+ self = [super init];
59
+ if (self)
60
+ {
61
+ // create the data source for this custom picker
62
+ NSMutableArray *viewArray = [[NSMutableArray alloc] init];
63
+
64
+ CustomView *earlyMorningView = [[CustomView alloc] initWithFrame:CGRectZero];
65
+ earlyMorningView.title = @"Early Morning";
66
+ earlyMorningView.image = [UIImage imageNamed:@"12-6AM.png"];
67
+ [viewArray addObject:earlyMorningView];
68
+ [earlyMorningView release];
69
+
70
+ CustomView *lateMorningView = [[CustomView alloc] initWithFrame:CGRectZero];
71
+ lateMorningView.title = @"Late Morning";
72
+ lateMorningView.image = [UIImage imageNamed:@"6-12AM.png"];
73
+ [viewArray addObject:lateMorningView];
74
+ [lateMorningView release];
75
+
76
+ CustomView *afternoonView = [[CustomView alloc] initWithFrame:CGRectZero];
77
+ afternoonView.title = @"Afternoon";
78
+ afternoonView.image = [UIImage imageNamed:@"12-6PM.png"];
79
+ [viewArray addObject:afternoonView];
80
+ [afternoonView release];
81
+
82
+ CustomView *eveningView = [[CustomView alloc] initWithFrame:CGRectZero];
83
+ eveningView.title = @"Evening";
84
+ eveningView.image = [UIImage imageNamed:@"6-12PM.png"];
85
+ [viewArray addObject:eveningView];
86
+ [eveningView release];
87
+
88
+ self.customPickerArray = viewArray;
89
+ [viewArray release];
90
+ }
91
+ return self;
92
+ }
93
+
94
+ - (void)dealloc
95
+ {
96
+ [customPickerArray release];
97
+ [super dealloc];
98
+ }
99
+
100
+
101
+ #pragma mark -
102
+ #pragma mark UIPickerViewDataSource
103
+
104
+ - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
105
+ {
106
+ return [CustomView viewWidth];
107
+ }
108
+
109
+ - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
110
+ {
111
+ return [CustomView viewHeight];
112
+ }
113
+
114
+ - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
115
+ {
116
+ return [customPickerArray count];
117
+ }
118
+
119
+ - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
120
+ {
121
+ return 1;
122
+ }
123
+
124
+
125
+ #pragma mark -
126
+ #pragma mark UIPickerViewDelegate
127
+
128
+ // tell the picker which view to use for a given component and row, we have an array of views to show
129
+ - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
130
+ forComponent:(NSInteger)component reusingView:(UIView *)view
131
+ {
132
+ return [customPickerArray objectAtIndex:row];
133
+ }
134
+
135
+ @end
@@ -0,0 +1,62 @@
1
+ /*
2
+ File: CustomView.h
3
+ Abstract: The custom view holding the image and title for the custom picker.
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 CustomView : UIView
51
+ {
52
+ NSString *title;
53
+ UIImage *image;
54
+ }
55
+
56
+ @property (nonatomic, retain) NSString *title;
57
+ @property (nonatomic, retain) UIImage *image;
58
+
59
+ + (CGFloat)viewWidth;
60
+ + (CGFloat)viewHeight;
61
+
62
+ @end
@@ -0,0 +1,119 @@
1
+ /*
2
+ File: CustomView.m
3
+ Abstract: The custom view holding the image and title for the custom picker.
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 "CustomView.h"
49
+
50
+ #define MAIN_FONT_SIZE 18
51
+ #define MIN_MAIN_FONT_SIZE 16
52
+
53
+ @implementation CustomView
54
+
55
+ @synthesize title, image;
56
+
57
+ const CGFloat kViewWidth = 200;
58
+ const CGFloat kViewHeight = 44;
59
+
60
+ + (CGFloat)viewWidth
61
+ {
62
+ return kViewWidth;
63
+ }
64
+
65
+ + (CGFloat)viewHeight
66
+ {
67
+ return kViewHeight;
68
+ }
69
+
70
+ - (id)initWithFrame:(CGRect)frame
71
+ {
72
+ // use predetermined frame size
73
+ if (self = [super initWithFrame:CGRectMake(0.0, 0.0, kViewWidth, kViewHeight)])
74
+ {
75
+ self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
76
+ self.backgroundColor = [UIColor clearColor]; // make the background transparent
77
+ }
78
+ return self;
79
+ }
80
+
81
+ - (void)drawRect:(CGRect)rect
82
+ {
83
+ // draw the image and title using their draw methods
84
+ CGFloat yCoord = (self.bounds.size.height - self.image.size.height) / 2;
85
+ CGPoint point = CGPointMake(10.0, yCoord);
86
+ [self.image drawAtPoint:point];
87
+
88
+ yCoord = (self.bounds.size.height - MAIN_FONT_SIZE) / 2;
89
+ point = CGPointMake(10.0 + self.image.size.width + 10.0, yCoord);
90
+ [self.title drawAtPoint:point
91
+ forWidth:self.bounds.size.width
92
+ withFont:[UIFont systemFontOfSize:MAIN_FONT_SIZE]
93
+ minFontSize:MIN_MAIN_FONT_SIZE
94
+ actualFontSize:NULL
95
+ lineBreakMode:UILineBreakModeTailTruncation
96
+ baselineAdjustment:UIBaselineAdjustmentAlignBaselines];
97
+ }
98
+
99
+ // Enable accessibility for this view.
100
+ - (BOOL)isAccessibilityElement
101
+ {
102
+ return YES;
103
+ }
104
+
105
+ // Return a string that describes this view.
106
+ - (NSString *)accessibilityLabel
107
+ {
108
+ return self.title;
109
+ }
110
+
111
+ - (void)dealloc
112
+ {
113
+ [title release];
114
+ [image release];
115
+
116
+ [super dealloc];
117
+ }
118
+
119
+ @end