Skip to content

Commit a012e99

Browse files
author
Jim Dovey
committed
Implemented a new demo project to show iPhoto-style expansion of grid items from a single point.
1 parent be175b6 commit a012e99

22 files changed

Lines changed: 5257 additions & 1 deletion

AQGridView.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/ExpanderDemo/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.xcodeproj/*.mode1v3
2+
*.xcodeproj/*.pbxuser
3+
**/xcuserdata
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* ExpandFromGridViewCell.h
3+
* Classes
4+
*
5+
* Created by Jim Dovey on 16/8/2010.
6+
*
7+
* Copyright (c) 2010 Jim Dovey
8+
* All rights reserved.
9+
*
10+
* Redistribution and use in source and binary forms, with or without
11+
* modification, are permitted provided that the following conditions
12+
* are met:
13+
*
14+
* Redistributions of source code must retain the above copyright notice,
15+
* this list of conditions and the following disclaimer.
16+
*
17+
* Redistributions in binary form must reproduce the above copyright
18+
* notice, this list of conditions and the following disclaimer in the
19+
* documentation and/or other materials provided with the distribution.
20+
*
21+
* Neither the name of the project's author nor the names of its
22+
* contributors may be used to endorse or promote products derived from
23+
* this software without specific prior written permission.
24+
*
25+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29+
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31+
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36+
*
37+
*/
38+
39+
#import <Foundation/Foundation.h>
40+
#import "ImageGridViewCell.h"
41+
42+
@interface ExpandFromGridViewCell : ImageGridViewCell
43+
- (CGRect) rectForExpansionStart;
44+
@end
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* ExpandFromGridViewCell.h
3+
* Classes
4+
*
5+
* Created by Jim Dovey on 16/8/2010.
6+
*
7+
* Copyright (c) 2010 Jim Dovey
8+
* All rights reserved.
9+
*
10+
* Redistribution and use in source and binary forms, with or without
11+
* modification, are permitted provided that the following conditions
12+
* are met:
13+
*
14+
* Redistributions of source code must retain the above copyright notice,
15+
* this list of conditions and the following disclaimer.
16+
*
17+
* Redistributions in binary form must reproduce the above copyright
18+
* notice, this list of conditions and the following disclaimer in the
19+
* documentation and/or other materials provided with the distribution.
20+
*
21+
* Neither the name of the project's author nor the names of its
22+
* contributors may be used to endorse or promote products derived from
23+
* this software without specific prior written permission.
24+
*
25+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29+
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31+
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36+
*
37+
*/
38+
39+
#import "ExpandFromGridViewCell.h"
40+
41+
@implementation ExpandFromGridViewCell
42+
43+
- (CGRect) rectForExpansionStart
44+
{
45+
return ( _imageView.frame );
46+
}
47+
48+
@end
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* ExpanderDemoAppDelegate.h
3+
* Classes
4+
*
5+
* Created by Jim Dovey on 16/8/2010.
6+
*
7+
* Copyright (c) 2010 Jim Dovey
8+
* All rights reserved.
9+
*
10+
* Redistribution and use in source and binary forms, with or without
11+
* modification, are permitted provided that the following conditions
12+
* are met:
13+
*
14+
* Redistributions of source code must retain the above copyright notice,
15+
* this list of conditions and the following disclaimer.
16+
*
17+
* Redistributions in binary form must reproduce the above copyright
18+
* notice, this list of conditions and the following disclaimer in the
19+
* documentation and/or other materials provided with the distribution.
20+
*
21+
* Neither the name of the project's author nor the names of its
22+
* contributors may be used to endorse or promote products derived from
23+
* this software without specific prior written permission.
24+
*
25+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29+
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31+
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36+
*
37+
*/
38+
39+
40+
#import <UIKit/UIKit.h>
41+
42+
@class ExpanderDemoViewController;
43+
44+
@interface ExpanderDemoAppDelegate : NSObject <UIApplicationDelegate> {
45+
46+
UIWindow *window;
47+
48+
ExpanderDemoViewController *viewController;
49+
}
50+
51+
@property (nonatomic, retain) IBOutlet UIWindow *window;
52+
53+
54+
@property (nonatomic, retain) IBOutlet ExpanderDemoViewController *viewController;
55+
56+
@end
57+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* ExpanderDemoAppDelegate.h
3+
* Classes
4+
*
5+
* Created by Jim Dovey on 16/8/2010.
6+
*
7+
* Copyright (c) 2010 Jim Dovey
8+
* All rights reserved.
9+
*
10+
* Redistribution and use in source and binary forms, with or without
11+
* modification, are permitted provided that the following conditions
12+
* are met:
13+
*
14+
* Redistributions of source code must retain the above copyright notice,
15+
* this list of conditions and the following disclaimer.
16+
*
17+
* Redistributions in binary form must reproduce the above copyright
18+
* notice, this list of conditions and the following disclaimer in the
19+
* documentation and/or other materials provided with the distribution.
20+
*
21+
* Neither the name of the project's author nor the names of its
22+
* contributors may be used to endorse or promote products derived from
23+
* this software without specific prior written permission.
24+
*
25+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29+
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31+
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36+
*
37+
*/
38+
39+
40+
#import "ExpanderDemoAppDelegate.h"
41+
42+
#import "ExpanderDemoViewController.h"
43+
44+
@implementation ExpanderDemoAppDelegate
45+
46+
47+
@synthesize window;
48+
49+
@synthesize viewController;
50+
51+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
52+
53+
// Override point for customization after application launch.
54+
viewController.view.frame = [[UIScreen mainScreen] applicationFrame];
55+
56+
[window addSubview:viewController.view];
57+
[window makeKeyAndVisible];
58+
return YES;
59+
}
60+
61+
- (void)applicationWillTerminate:(UIApplication *)application {
62+
63+
// Save data if appropriate.
64+
}
65+
66+
- (void)dealloc {
67+
68+
[window release];
69+
[viewController release];
70+
[super dealloc];
71+
}
72+
73+
@end
74+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* ExpanderDemoViewController.h
3+
* Classes
4+
*
5+
* Created by Jim Dovey on 16/8/2010.
6+
*
7+
* Copyright (c) 2010 Jim Dovey
8+
* All rights reserved.
9+
*
10+
* Redistribution and use in source and binary forms, with or without
11+
* modification, are permitted provided that the following conditions
12+
* are met:
13+
*
14+
* Redistributions of source code must retain the above copyright notice,
15+
* this list of conditions and the following disclaimer.
16+
*
17+
* Redistributions in binary form must reproduce the above copyright
18+
* notice, this list of conditions and the following disclaimer in the
19+
* documentation and/or other materials provided with the distribution.
20+
*
21+
* Neither the name of the project's author nor the names of its
22+
* contributors may be used to endorse or promote products derived from
23+
* this software without specific prior written permission.
24+
*
25+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29+
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31+
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36+
*
37+
*/
38+
39+
#import <UIKit/UIKit.h>
40+
#import "AQGridViewController.h"
41+
42+
@interface ExpanderDemoViewController : AQGridViewController {
43+
44+
}
45+
46+
@end
47+
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* ExpanderDemoViewController.h
3+
* Classes
4+
*
5+
* Created by Jim Dovey on 16/8/2010.
6+
*
7+
* Copyright (c) 2010 Jim Dovey
8+
* All rights reserved.
9+
*
10+
* Redistribution and use in source and binary forms, with or without
11+
* modification, are permitted provided that the following conditions
12+
* are met:
13+
*
14+
* Redistributions of source code must retain the above copyright notice,
15+
* this list of conditions and the following disclaimer.
16+
*
17+
* Redistributions in binary form must reproduce the above copyright
18+
* notice, this list of conditions and the following disclaimer in the
19+
* documentation and/or other materials provided with the distribution.
20+
*
21+
* Neither the name of the project's author nor the names of its
22+
* contributors may be used to endorse or promote products derived from
23+
* this software without specific prior written permission.
24+
*
25+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29+
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31+
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36+
*
37+
*/
38+
39+
#import "ExpanderDemoViewController.h"
40+
#import "AQGridView.h"
41+
#import "ExpandFromGridViewCell.h"
42+
#import "ExpandingGridViewController.h"
43+
44+
@implementation ExpanderDemoViewController
45+
46+
// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
47+
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
48+
{
49+
return YES;
50+
}
51+
52+
#pragma mark -
53+
#pragma mark AQGridView Data Source
54+
55+
- (NSUInteger) numberOfItemsInGridView: (AQGridView *) gridView
56+
{
57+
return ( 1 );
58+
}
59+
60+
- (AQGridViewCell *) gridView: (AQGridView *) gridView cellForItemAtIndex: (NSUInteger) index
61+
{
62+
static NSString * ExpanderCellIdentifier = @"ExpanderCellIdentifier";
63+
64+
ExpandFromGridViewCell * cell = (ExpandFromGridViewCell *)[self.gridView dequeueReusableCellWithIdentifier: ExpanderCellIdentifier];
65+
if ( cell == nil )
66+
{
67+
cell = [[[ExpandFromGridViewCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 200.0, 150.0) reuseIdentifier: ExpanderCellIdentifier] autorelease];
68+
cell.selectionGlowColor = [UIColor purpleColor];
69+
}
70+
71+
cell.image = [UIImage imageNamed: @"Dragon.png"];
72+
return ( cell );
73+
}
74+
75+
- (CGSize) portraitGridCellSizeForGridView: (AQGridView *) gridView
76+
{
77+
return ( CGSizeMake(224.0, 168.0) );
78+
}
79+
80+
#pragma mark -
81+
#pragma mark AQGridView Delegate
82+
83+
- (void) gridView: (AQGridView *) gridView didSelectItemAtIndex: (NSUInteger) index
84+
{
85+
ExpandFromGridViewCell * cell = (ExpandFromGridViewCell *)[self.gridView cellForItemAtIndex: index];
86+
CGRect expandFromRect = [cell rectForExpansionStart];
87+
88+
ExpandingGridViewController * controller = [[ExpandingGridViewController alloc] init];
89+
controller.gridView.frame = self.gridView.frame;
90+
91+
[controller viewWillAppear: NO];
92+
[self.view.superview addSubview: controller.gridView];
93+
[controller expandCellsFromRect: expandFromRect ofView: cell];
94+
[controller viewDidAppear: NO];
95+
}
96+
97+
@end

0 commit comments

Comments
 (0)