Skip to content

Commit 7137156

Browse files
author
Darcy Liu
committed
add CollectionView-Simple
1 parent 0ac736e commit 7137156

87 files changed

Lines changed: 1514 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CollectionView-Simple.zip

10.1 MB
Binary file not shown.

CollectionView-Simple/CollectionView.xcodeproj/project.pbxproj

Lines changed: 592 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
File: AppDelegate.h
3+
Abstract: The sample's application delegate.
4+
5+
Version: 1.0
6+
7+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
8+
Inc. ("Apple") in consideration of your agreement to the following
9+
terms, and your use, installation, modification or redistribution of
10+
this Apple software constitutes acceptance of these terms. If you do
11+
not agree with these terms, please do not use, install, modify or
12+
redistribute this Apple software.
13+
14+
In consideration of your agreement to abide by the following terms, and
15+
subject to these terms, Apple grants you a personal, non-exclusive
16+
license, under Apple's copyrights in this original Apple software (the
17+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
18+
Software, with or without modifications, in source and/or binary forms;
19+
provided that if you redistribute the Apple Software in its entirety and
20+
without modifications, you must retain this notice and the following
21+
text and disclaimers in all such redistributions of the Apple Software.
22+
Neither the name, trademarks, service marks or logos of Apple Inc. may
23+
be used to endorse or promote products derived from the Apple Software
24+
without specific prior written permission from Apple. Except as
25+
expressly stated in this notice, no other rights or licenses, express or
26+
implied, are granted by Apple herein, including but not limited to any
27+
patent rights that may be infringed by your derivative works or by other
28+
works in which the Apple Software may be incorporated.
29+
30+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
31+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
32+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
33+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
34+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
35+
36+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
37+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
40+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
41+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
42+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
43+
POSSIBILITY OF SUCH DAMAGE.
44+
45+
Copyright (C) 2012 Apple Inc. All Rights Reserved.
46+
47+
*/
48+
49+
#import <UIKit/UIKit.h>
50+
51+
@interface AppDelegate : UIResponder <UIApplicationDelegate>
52+
53+
@end
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
File: AppDelegate.m
3+
Abstract: The sample's application delegate.
4+
5+
Version: 1.0
6+
7+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
8+
Inc. ("Apple") in consideration of your agreement to the following
9+
terms, and your use, installation, modification or redistribution of
10+
this Apple software constitutes acceptance of these terms. If you do
11+
not agree with these terms, please do not use, install, modify or
12+
redistribute this Apple software.
13+
14+
In consideration of your agreement to abide by the following terms, and
15+
subject to these terms, Apple grants you a personal, non-exclusive
16+
license, under Apple's copyrights in this original Apple software (the
17+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
18+
Software, with or without modifications, in source and/or binary forms;
19+
provided that if you redistribute the Apple Software in its entirety and
20+
without modifications, you must retain this notice and the following
21+
text and disclaimers in all such redistributions of the Apple Software.
22+
Neither the name, trademarks, service marks or logos of Apple Inc. may
23+
be used to endorse or promote products derived from the Apple Software
24+
without specific prior written permission from Apple. Except as
25+
expressly stated in this notice, no other rights or licenses, express or
26+
implied, are granted by Apple herein, including but not limited to any
27+
patent rights that may be infringed by your derivative works or by other
28+
works in which the Apple Software may be incorporated.
29+
30+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
31+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
32+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
33+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
34+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
35+
36+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
37+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
40+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
41+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
42+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
43+
POSSIBILITY OF SUCH DAMAGE.
44+
45+
Copyright (C) 2012 Apple Inc. All Rights Reserved.
46+
47+
*/
48+
49+
#import "AppDelegate.h"
50+
51+
@implementation AppDelegate
52+
53+
@synthesize window = _window;
54+
55+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
56+
{
57+
// Override point for customization after application launch.
58+
return YES;
59+
}
60+
61+
- (void)applicationWillResignActive:(UIApplication *)application
62+
{
63+
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
64+
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
65+
}
66+
67+
- (void)applicationDidEnterBackground:(UIApplication *)application
68+
{
69+
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
70+
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
71+
}
72+
73+
- (void)applicationWillEnterForeground:(UIApplication *)application
74+
{
75+
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
76+
}
77+
78+
- (void)applicationDidBecomeActive:(UIApplication *)application
79+
{
80+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
81+
}
82+
83+
- (void)applicationWillTerminate:(UIApplication *)application
84+
{
85+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
86+
}
87+
88+
@end
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
File: Cell.h
3+
Abstract: Custom collection view cell for image and its label.
4+
5+
Version: 1.0
6+
7+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
8+
Inc. ("Apple") in consideration of your agreement to the following
9+
terms, and your use, installation, modification or redistribution of
10+
this Apple software constitutes acceptance of these terms. If you do
11+
not agree with these terms, please do not use, install, modify or
12+
redistribute this Apple software.
13+
14+
In consideration of your agreement to abide by the following terms, and
15+
subject to these terms, Apple grants you a personal, non-exclusive
16+
license, under Apple's copyrights in this original Apple software (the
17+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
18+
Software, with or without modifications, in source and/or binary forms;
19+
provided that if you redistribute the Apple Software in its entirety and
20+
without modifications, you must retain this notice and the following
21+
text and disclaimers in all such redistributions of the Apple Software.
22+
Neither the name, trademarks, service marks or logos of Apple Inc. may
23+
be used to endorse or promote products derived from the Apple Software
24+
without specific prior written permission from Apple. Except as
25+
expressly stated in this notice, no other rights or licenses, express or
26+
implied, are granted by Apple herein, including but not limited to any
27+
patent rights that may be infringed by your derivative works or by other
28+
works in which the Apple Software may be incorporated.
29+
30+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
31+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
32+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
33+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
34+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
35+
36+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
37+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
40+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
41+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
42+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
43+
POSSIBILITY OF SUCH DAMAGE.
44+
45+
Copyright (C) 2012 Apple Inc. All Rights Reserved.
46+
47+
*/
48+
49+
#import <UIKit/UIKit.h>
50+
51+
@interface Cell : UICollectionViewCell
52+
53+
@property (strong, nonatomic) IBOutlet UIImageView *image;
54+
@property (strong, nonatomic) IBOutlet UILabel *label;
55+
56+
@end
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
File: Cell.m
3+
Abstract: Custom collection view cell for image and its label.
4+
5+
Version: 1.0
6+
7+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
8+
Inc. ("Apple") in consideration of your agreement to the following
9+
terms, and your use, installation, modification or redistribution of
10+
this Apple software constitutes acceptance of these terms. If you do
11+
not agree with these terms, please do not use, install, modify or
12+
redistribute this Apple software.
13+
14+
In consideration of your agreement to abide by the following terms, and
15+
subject to these terms, Apple grants you a personal, non-exclusive
16+
license, under Apple's copyrights in this original Apple software (the
17+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
18+
Software, with or without modifications, in source and/or binary forms;
19+
provided that if you redistribute the Apple Software in its entirety and
20+
without modifications, you must retain this notice and the following
21+
text and disclaimers in all such redistributions of the Apple Software.
22+
Neither the name, trademarks, service marks or logos of Apple Inc. may
23+
be used to endorse or promote products derived from the Apple Software
24+
without specific prior written permission from Apple. Except as
25+
expressly stated in this notice, no other rights or licenses, express or
26+
implied, are granted by Apple herein, including but not limited to any
27+
patent rights that may be infringed by your derivative works or by other
28+
works in which the Apple Software may be incorporated.
29+
30+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
31+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
32+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
33+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
34+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
35+
36+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
37+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
40+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
41+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
42+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
43+
POSSIBILITY OF SUCH DAMAGE.
44+
45+
Copyright (C) 2012 Apple Inc. All Rights Reserved.
46+
47+
*/
48+
49+
#import "Cell.h"
50+
#import "CustomCellBackground.h"
51+
52+
@implementation Cell
53+
54+
- (id)initWithCoder:(NSCoder *)aDecoder
55+
{
56+
self = [super initWithCoder:aDecoder];
57+
if (self)
58+
{
59+
// change to our custom selected background view
60+
CustomCellBackground *backgroundView = [[CustomCellBackground alloc] initWithFrame:CGRectZero];
61+
self.selectedBackgroundView = backgroundView;
62+
}
63+
return self;
64+
}
65+
66+
@end
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>${PRODUCT_NAME}</string>
9+
<key>CFBundleExecutable</key>
10+
<string>${EXECUTABLE_NAME}</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>company.${PRODUCT_NAME:rfc1034identifier}</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>${PRODUCT_NAME}</string>
17+
<key>CFBundlePackageType</key>
18+
<string>APPL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleSignature</key>
22+
<string>????</string>
23+
<key>CFBundleVersion</key>
24+
<string>1.0</string>
25+
<key>LSRequiresIPhoneOS</key>
26+
<true/>
27+
<key>UIMainStoryboardFile</key>
28+
<string>MainStoryboard</string>
29+
<key>UIRequiredDeviceCapabilities</key>
30+
<array>
31+
<string>armv7</string>
32+
</array>
33+
<key>UISupportedInterfaceOrientations</key>
34+
<array>
35+
<string>UIInterfaceOrientationPortrait</string>
36+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
37+
<string>UIInterfaceOrientationLandscapeLeft</string>
38+
<string>UIInterfaceOrientationLandscapeRight</string>
39+
</array>
40+
</dict>
41+
</plist>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// Prefix header for all source files of the 'CollectionView' target in the 'CollectionView' project
3+
//
4+
5+
#import <Availability.h>
6+
7+
#ifndef __IPHONE_6_0
8+
#warning "This project uses features only available in iOS SDK 6.0 and later."
9+
#endif
10+
11+
#ifdef __OBJC__
12+
#import <UIKit/UIKit.h>
13+
#import <Foundation/Foundation.h>
14+
#endif
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
File: CustomCellBackground.h
3+
Abstract: Custom UIView to draw a rounded blue box to represent a selected cell.
4+
5+
Version: 1.0
6+
7+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
8+
Inc. ("Apple") in consideration of your agreement to the following
9+
terms, and your use, installation, modification or redistribution of
10+
this Apple software constitutes acceptance of these terms. If you do
11+
not agree with these terms, please do not use, install, modify or
12+
redistribute this Apple software.
13+
14+
In consideration of your agreement to abide by the following terms, and
15+
subject to these terms, Apple grants you a personal, non-exclusive
16+
license, under Apple's copyrights in this original Apple software (the
17+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
18+
Software, with or without modifications, in source and/or binary forms;
19+
provided that if you redistribute the Apple Software in its entirety and
20+
without modifications, you must retain this notice and the following
21+
text and disclaimers in all such redistributions of the Apple Software.
22+
Neither the name, trademarks, service marks or logos of Apple Inc. may
23+
be used to endorse or promote products derived from the Apple Software
24+
without specific prior written permission from Apple. Except as
25+
expressly stated in this notice, no other rights or licenses, express or
26+
implied, are granted by Apple herein, including but not limited to any
27+
patent rights that may be infringed by your derivative works or by other
28+
works in which the Apple Software may be incorporated.
29+
30+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
31+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
32+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
33+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
34+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
35+
36+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
37+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
40+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
41+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
42+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
43+
POSSIBILITY OF SUCH DAMAGE.
44+
45+
Copyright (C) 2012 Apple Inc. All Rights Reserved.
46+
47+
*/
48+
49+
#import <UIKit/UIKit.h>
50+
51+
@interface CustomCellBackground : UIView
52+
53+
@end

0 commit comments

Comments
 (0)