iCuke 0.4.12 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,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
|
+
|