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,303 @@
1
+ /*
2
+ File: ToolbarViewController.m
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 "ToolbarViewController.h"
49
+ #import "AppDelegate.h"
50
+ #import "Constants.h"
51
+
52
+ @implementation ToolbarViewController
53
+
54
+ @synthesize barStyleSegControl, tintSwitch, buttonItemStyleSegControl, systemButtonPicker;
55
+ @synthesize toolbar, pickerViewArray;
56
+
57
+ - (void)dealloc
58
+ {
59
+ [toolbar release];
60
+ [pickerViewArray release];
61
+
62
+ [barStyleSegControl release];
63
+ [tintSwitch release];
64
+ [buttonItemStyleSegControl release];
65
+ [systemButtonPicker release];
66
+
67
+ [super dealloc];
68
+ }
69
+
70
+ // return the picker frame based on its size, positioned at the bottom of the page
71
+ - (CGRect)pickerFrameWithSize:(CGSize)size
72
+ {
73
+ CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
74
+ CGRect pickerRect = CGRectMake( 0.0,
75
+ screenRect.size.height - 84.0 - size.height,
76
+ size.width,
77
+ size.height);
78
+ return pickerRect;
79
+ }
80
+
81
+ - (void)createToolbarItems
82
+ {
83
+ // match each of the toolbar item's style match the selection in the "UIBarButtonItemStyle" segmented control
84
+ UIBarButtonItemStyle style = [self.buttonItemStyleSegControl selectedSegmentIndex];
85
+
86
+ // create the system-defined "OK or Done" button
87
+ UIBarButtonItem *systemItem = [[UIBarButtonItem alloc]
88
+ initWithBarButtonSystemItem:currentSystemItem
89
+ target:self action:@selector(action:)];
90
+ systemItem.style = style;
91
+
92
+ // flex item used to separate the left groups items and right grouped items
93
+ UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
94
+ target:nil
95
+ action:nil];
96
+
97
+ // create a special tab bar item with a custom image and title
98
+ UIBarButtonItem *infoItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"segment_tools.png"]
99
+ style:style
100
+ target:self
101
+ action:@selector(action:)];
102
+ // Set the accessibility label for an image bar item.
103
+ [infoItem setAccessibilityLabel:NSLocalizedString(@"ToolsIcon", @"")];
104
+
105
+ // create a bordered style button with custom title
106
+ UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithTitle:@"Item"
107
+ style:style // note you can use "UIBarButtonItemStyleDone" to make it blue
108
+ target:self
109
+ action:@selector(action:)];
110
+
111
+ NSArray *items = [NSArray arrayWithObjects: systemItem, flexItem, customItem, infoItem, nil];
112
+ [self.toolbar setItems:items animated:NO];
113
+
114
+ [systemItem release];
115
+ [flexItem release];
116
+ [infoItem release];
117
+ [customItem release];
118
+ }
119
+
120
+ // called after the view controller's view is released and set to nil.
121
+ // For example, a memory warning which causes the view to be purged. Not invoked as a result of -dealloc.
122
+ // So release any properties that are loaded in viewDidLoad or can be recreated lazily.
123
+ //
124
+ - (void)viewDidUnload
125
+ {
126
+ [super viewDidUnload];
127
+
128
+ // release and set to nil
129
+ self.pickerViewArray = nil;
130
+ self.toolbar = nil;
131
+ }
132
+
133
+ - (void)viewDidLoad
134
+ {
135
+ [super viewDidLoad];
136
+
137
+ // this list appears in the UIPickerView to pick the system's UIBarButtonItem
138
+ self.pickerViewArray = [NSArray arrayWithObjects:
139
+ @"Done",
140
+ @"Cancel",
141
+ @"Edit",
142
+ @"Save",
143
+ @"Add",
144
+ @"FlexibleSpace",
145
+ @"FixedSpace",
146
+ @"Compose",
147
+ @"Reply",
148
+ @"Action",
149
+ @"Organize",
150
+ @"Bookmarks",
151
+ @"Search",
152
+ @"Refresh",
153
+ @"Stop",
154
+ @"Camera",
155
+ @"Trash",
156
+ @"Play",
157
+ @"Pause",
158
+ @"Rewind",
159
+ @"FastForward",
160
+ // new in 3.0 SDK:
161
+ @"Undo",
162
+ @"Redo",
163
+ nil];
164
+
165
+ self.title = NSLocalizedString(@"ToolbarTitle", @"");
166
+
167
+ self.view.backgroundColor = [UIColor groupTableViewBackgroundColor]; // use the table view background color
168
+
169
+ // create the UIToolbar at the bottom of the view controller
170
+ //
171
+ toolbar = [UIToolbar new];
172
+ toolbar.barStyle = UIBarStyleDefault;
173
+
174
+ // size up the toolbar and set its frame
175
+ [toolbar sizeToFit];
176
+ CGFloat toolbarHeight = [toolbar frame].size.height;
177
+ CGRect mainViewBounds = self.view.bounds;
178
+ [toolbar setFrame:CGRectMake(CGRectGetMinX(mainViewBounds),
179
+ CGRectGetMinY(mainViewBounds) + CGRectGetHeight(mainViewBounds) - (toolbarHeight * 2.0) + 2.0,
180
+ CGRectGetWidth(mainViewBounds),
181
+ toolbarHeight)];
182
+
183
+ [self.view addSubview:toolbar];
184
+
185
+ currentSystemItem = UIBarButtonSystemItemDone;
186
+ [self createToolbarItems];
187
+
188
+ // Set the accessibility label for the tint switch so that its context can be determined.
189
+ [self.tintSwitch setAccessibilityLabel:NSLocalizedString(@"TintSwitch", @"")];
190
+ }
191
+
192
+ - (IBAction)toggleStyle:(id)sender
193
+ {
194
+ UIBarButtonItemStyle style = UIBarButtonItemStylePlain;
195
+
196
+ switch ([sender selectedSegmentIndex])
197
+ {
198
+ case 0: // UIBarButtonItemStylePlain
199
+ {
200
+ style = UIBarButtonItemStylePlain;
201
+ break;
202
+ }
203
+ case 1: // UIBarButtonItemStyleBordered
204
+ {
205
+ style = UIBarButtonItemStyleBordered;
206
+ break;
207
+ }
208
+ case 2: // UIBarButtonItemStyleDone
209
+ {
210
+ style = UIBarButtonItemStyleDone;
211
+ break;
212
+ }
213
+ }
214
+
215
+ NSArray *toolbarItems = toolbar.items;
216
+ UIBarButtonItem *item;
217
+ for (item in toolbarItems)
218
+ {
219
+ item.style = style;
220
+ }
221
+ }
222
+
223
+ - (IBAction)toggleBarStyle:(id)sender
224
+ {
225
+ switch ([sender selectedSegmentIndex])
226
+ {
227
+ case 0:
228
+ toolbar.barStyle = UIBarStyleDefault;
229
+ break;
230
+ case 1:
231
+ toolbar.barStyle = UIBarStyleBlackOpaque;
232
+ break;
233
+ case 2:
234
+ toolbar.barStyle = UIBarStyleBlackTranslucent;
235
+ break;
236
+ }
237
+ }
238
+
239
+ - (IBAction)toggleTintColor:(id)sender
240
+ {
241
+ UISwitch *switchCtl = (UISwitch *)sender;
242
+ if (switchCtl.on)
243
+ {
244
+ toolbar.tintColor = [UIColor redColor];
245
+ barStyleSegControl.enabled = NO;
246
+ barStyleSegControl.alpha = 0.50;
247
+ }
248
+ else
249
+ {
250
+ toolbar.tintColor = nil; // no color
251
+ barStyleSegControl.enabled = YES;
252
+ barStyleSegControl.alpha = 1.0;
253
+ }
254
+ }
255
+
256
+ - (void)action:(id)sender
257
+ {
258
+ //NSLog(@"UIBarButtonItem clicked");
259
+ }
260
+
261
+
262
+ #pragma mark -
263
+ #pragma mark UIPickerViewDelegate
264
+
265
+ - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
266
+ {
267
+ // change the left most bar item to what's in the picker
268
+ currentSystemItem = [pickerView selectedRowInComponent:0];
269
+ [self createToolbarItems]; // this will re-create all the items
270
+ }
271
+
272
+
273
+ #pragma mark -
274
+ #pragma mark UIPickerViewDataSource
275
+
276
+ - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
277
+ {
278
+ return [pickerViewArray objectAtIndex:row];
279
+ }
280
+
281
+ - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
282
+ {
283
+ return 240.0;
284
+ }
285
+
286
+ - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
287
+ {
288
+ return 40.0;
289
+ }
290
+
291
+ - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
292
+ {
293
+ return [pickerViewArray count];
294
+ }
295
+
296
+ - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
297
+ {
298
+ return 1;
299
+ }
300
+
301
+ @end
302
+
303
+
@@ -0,0 +1,64 @@
1
+ /*
2
+ File: TransitionViewController.h
3
+ Abstract: The view controller for showing transitions with UIView.
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 TransitionsViewController : UIViewController
51
+ {
52
+ UIView *containerView;
53
+ UIImageView *mainView;
54
+ UIImageView *flipToView;
55
+ }
56
+
57
+ @property (nonatomic, retain) UIView *containerView;
58
+ @property (nonatomic, retain) UIImageView *mainView;
59
+ @property (nonatomic, retain) UIImageView *flipToView;
60
+
61
+ - (IBAction)curlAction:(id)sender;
62
+ - (IBAction)flipAction:(id)sender;
63
+
64
+ @end
@@ -0,0 +1,178 @@
1
+ /*
2
+ File: TransitionViewController.m
3
+ Abstract: The view controller for showing transitions with UIView.
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 "TransitionViewController.h"
49
+ #import "Constants.h"
50
+
51
+ #define kImageHeight 200.0
52
+ #define kImageWidth 250.0
53
+ #define kTransitionDuration 0.75
54
+ #define kTopPlacement 80.0 // y coord for the images
55
+
56
+ #pragma mark -
57
+ @implementation TransitionsViewController
58
+
59
+ @synthesize containerView, mainView, flipToView;
60
+
61
+ - (void)dealloc
62
+ {
63
+ [mainView release];
64
+ [flipToView release];
65
+ [containerView release];
66
+
67
+ [super dealloc];
68
+ }
69
+
70
+ - (void)viewDidLoad
71
+ {
72
+ [super viewDidLoad];
73
+
74
+ self.title = NSLocalizedString(@"TransitionsTitle", @"");
75
+
76
+ // create the container view which we will use for transition animation (centered horizontally)
77
+ CGRect frame = CGRectMake(round((self.view.bounds.size.width - kImageWidth) / 2.0),
78
+ kTopPlacement, kImageWidth, kImageHeight);
79
+ self.containerView = [[[UIView alloc] initWithFrame:frame] autorelease];
80
+ [self.view addSubview:self.containerView];
81
+
82
+ // The container view can represent the images for accessibility.
83
+ [self.containerView setIsAccessibilityElement:YES];
84
+ [self.containerView setAccessibilityLabel:NSLocalizedString(@"ImagesTitle", @"")];
85
+
86
+ // create the initial image view
87
+ frame = CGRectMake(0.0, 0.0, kImageWidth, kImageHeight);
88
+ self.mainView = [[[UIImageView alloc] initWithFrame:frame] autorelease];
89
+ self.mainView.image = [UIImage imageNamed:@"scene1.jpg"];
90
+ [self.containerView addSubview:self.mainView];
91
+
92
+ // create the alternate image view (to transition between)
93
+ CGRect imageFrame = CGRectMake(0.0, 0.0, kImageWidth, kImageHeight);
94
+ self.flipToView = [[[UIImageView alloc] initWithFrame:imageFrame] autorelease];
95
+ self.flipToView.image = [UIImage imageNamed:@"scene2.jpg"];
96
+ }
97
+
98
+ // called after the view controller's view is released and set to nil.
99
+ // For example, a memory warning which causes the view to be purged. Not invoked as a result of -dealloc.
100
+ // So release any properties that are loaded in viewDidLoad or can be recreated lazily.
101
+ //
102
+ - (void)viewDidUnload
103
+ {
104
+ [super viewDidUnload];
105
+
106
+ self.containerView = nil;
107
+ self.flipToView = nil;
108
+ self.mainView = nil;
109
+ }
110
+
111
+ - (IBAction)curlAction:(id)sender
112
+ {
113
+ [UIView beginAnimations:nil context:NULL];
114
+ [UIView setAnimationDuration:kTransitionDuration];
115
+
116
+ [UIView setAnimationTransition:([self.mainView superview] ?
117
+ UIViewAnimationTransitionCurlUp : UIViewAnimationTransitionCurlDown)
118
+ forView:self.containerView cache:YES];
119
+ if ([self.flipToView superview])
120
+ {
121
+ [self.flipToView removeFromSuperview];
122
+ [self.containerView addSubview:self.mainView];
123
+ }
124
+ else
125
+ {
126
+ [self.mainView removeFromSuperview];
127
+ [self.containerView addSubview:self.flipToView];
128
+ }
129
+
130
+ [UIView commitAnimations];
131
+ }
132
+
133
+ - (IBAction)flipAction:(id)sender
134
+ {
135
+ [UIView beginAnimations:nil context:NULL];
136
+ [UIView setAnimationDuration:kTransitionDuration];
137
+
138
+ [UIView setAnimationTransition:([self.mainView superview] ?
139
+ UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight)
140
+ forView:self.containerView cache:YES];
141
+ if ([flipToView superview])
142
+ {
143
+ [self.flipToView removeFromSuperview];
144
+ [self.containerView addSubview:mainView];
145
+ }
146
+ else
147
+ {
148
+ [self.mainView removeFromSuperview];
149
+ [self.containerView addSubview:flipToView];
150
+ }
151
+
152
+ [UIView commitAnimations];
153
+ }
154
+
155
+
156
+ #pragma mark -
157
+ #pragma mark UIViewController delegate methods
158
+
159
+ // called after this controller's view was dismissed, covered or otherwise hidden
160
+ - (void)viewWillDisappear:(BOOL)animated
161
+ {
162
+ // restore the nav bar and status bar color to default
163
+ self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
164
+ [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
165
+ }
166
+
167
+ // called after this controller's view will appear
168
+ - (void)viewWillAppear:(BOOL)animated
169
+ {
170
+ // for aesthetic reasons (the background is black), make the nav bar black for this particular page
171
+ self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
172
+
173
+ // match the status bar with the nav bar
174
+ [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
175
+ }
176
+
177
+ @end
178
+