├── .gitignore
├── CollectionView进阶——Cell长按事件
├── .gitignore
├── CollectionView-nib.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
├── CollectionView-nib
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── 0.imageset
│ │ │ ├── 0.png
│ │ │ └── Contents.json
│ │ ├── 1.imageset
│ │ │ ├── 1.png
│ │ │ └── Contents.json
│ │ ├── 2.imageset
│ │ │ ├── 2.png
│ │ │ └── Contents.json
│ │ ├── 3.imageset
│ │ │ ├── 3.png
│ │ │ └── Contents.json
│ │ ├── 4.imageset
│ │ │ ├── 4.png
│ │ │ └── Contents.json
│ │ ├── 5.imageset
│ │ │ ├── 5.png
│ │ │ └── Contents.json
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── home.imageset
│ │ │ ├── Contents.json
│ │ │ └── home.jpg
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── CollectionReusableView.h
│ ├── CollectionReusableView.m
│ ├── CollectionViewCell.h
│ ├── CollectionViewCell.m
│ ├── Info.plist
│ ├── SecondViewController.h
│ ├── SecondViewController.m
│ ├── SecondViewController.xib
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── CollectionView-nibTests
│ ├── CollectionView_nibTests.m
│ └── Info.plist
└── CollectionView-nibUITests
│ ├── CollectionView_nibUITests.m
│ └── Info.plist
├── CollectionView进阶——获取Cell中按钮点击事件
├── .gitignore
├── CollectionView-nib.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
├── CollectionView-nib
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── 0.imageset
│ │ │ ├── 0.png
│ │ │ └── Contents.json
│ │ ├── 1.imageset
│ │ │ ├── 1.png
│ │ │ └── Contents.json
│ │ ├── 2.imageset
│ │ │ ├── 2.png
│ │ │ └── Contents.json
│ │ ├── 3.imageset
│ │ │ ├── 3.png
│ │ │ └── Contents.json
│ │ ├── 4.imageset
│ │ │ ├── 4.png
│ │ │ └── Contents.json
│ │ ├── 5.imageset
│ │ │ ├── 5.png
│ │ │ └── Contents.json
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── home.imageset
│ │ │ ├── Contents.json
│ │ │ └── home.jpg
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── CollectionReusableView.h
│ ├── CollectionReusableView.m
│ ├── CollectionViewCell.h
│ ├── CollectionViewCell.m
│ ├── Info.plist
│ ├── SecondViewController.h
│ ├── SecondViewController.m
│ ├── SecondViewController.xib
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── CollectionView-nibTests
│ ├── CollectionView_nibTests.m
│ └── Info.plist
└── CollectionView-nibUITests
│ ├── CollectionView_nibUITests.m
│ └── Info.plist
├── README.md
├── Screenshots
├── 1.png
├── 2.png
├── 3.png
└── 4.png
├── Storyboard实现CollectionView
└── CollectionView-Storyboard
│ ├── .gitignore
│ ├── CollectionView-Storyboard.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── chenyufeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── chenyufeng.xcuserdatad
│ │ └── xcschemes
│ │ ├── CollectionView-Storyboard.xcscheme
│ │ └── xcschememanagement.plist
│ ├── CollectionView-Storyboard
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── 1.imageset
│ │ │ ├── 1.png
│ │ │ └── Contents.json
│ │ ├── 2.imageset
│ │ │ ├── 2.png
│ │ │ └── Contents.json
│ │ ├── 3.imageset
│ │ │ ├── 3.png
│ │ │ └── Contents.json
│ │ ├── 4.imageset
│ │ │ ├── 4.png
│ │ │ └── Contents.json
│ │ ├── 5.imageset
│ │ │ ├── 5.png
│ │ │ └── Contents.json
│ │ ├── 6.imageset
│ │ │ ├── 6.png
│ │ │ └── Contents.json
│ │ ├── 7.imageset
│ │ │ ├── 7.png
│ │ │ └── Contents.json
│ │ ├── 8.imageset
│ │ │ ├── 8.png
│ │ │ └── Contents.json
│ │ ├── 9.imageset
│ │ │ ├── 9.png
│ │ │ └── Contents.json
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── close.imageset
│ │ │ ├── Contents.json
│ │ │ └── close@2x.png
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── CollectionReusableView.h
│ ├── CollectionReusableView.m
│ ├── CollectionViewCell.h
│ ├── CollectionViewCell.m
│ ├── Info.plist
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
│ ├── CollectionView-StoryboardTests
│ ├── CollectionView_StoryboardTests.m
│ └── Info.plist
│ └── CollectionView-StoryboardUITests
│ ├── CollectionView_StoryboardUITests.m
│ └── Info.plist
├── nib实现CollectionView
└── CollectionView-nib
│ ├── .gitignore
│ ├── CollectionView-nib.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── chenyufeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── chenyufeng.xcuserdatad
│ │ └── xcschemes
│ │ ├── CollectionView-nib.xcscheme
│ │ └── xcschememanagement.plist
│ ├── CollectionView-nib
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── 1.imageset
│ │ │ ├── 1.png
│ │ │ └── Contents.json
│ │ ├── 2.imageset
│ │ │ ├── 2.png
│ │ │ └── Contents.json
│ │ ├── 3.imageset
│ │ │ ├── 3.png
│ │ │ └── Contents.json
│ │ ├── 4.imageset
│ │ │ ├── 4.png
│ │ │ └── Contents.json
│ │ ├── 5.imageset
│ │ │ ├── 5.png
│ │ │ └── Contents.json
│ │ ├── 6.imageset
│ │ │ ├── 6.png
│ │ │ └── Contents.json
│ │ ├── 7.imageset
│ │ │ ├── 7.png
│ │ │ └── Contents.json
│ │ ├── 8.imageset
│ │ │ ├── 8.png
│ │ │ └── Contents.json
│ │ ├── 9.imageset
│ │ │ ├── 9.png
│ │ │ └── Contents.json
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── CollectionReusableView.h
│ ├── CollectionReusableView.m
│ ├── CollectionViewCell.h
│ ├── CollectionViewCell.m
│ ├── Info.plist
│ ├── SecondViewController.h
│ ├── SecondViewController.m
│ ├── SecondViewController.xib
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
│ ├── CollectionView-nibTests
│ ├── CollectionView_nibTests.m
│ └── Info.plist
│ └── CollectionView-nibUITests
│ ├── CollectionView_nibUITests.m
│ └── Info.plist
├── 动态增加cell和section实现
├── .gitignore
├── CollectionView-nib.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
├── CollectionView-nib
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── 0.imageset
│ │ │ ├── 0.png
│ │ │ └── Contents.json
│ │ ├── 1.imageset
│ │ │ ├── 1.png
│ │ │ └── Contents.json
│ │ ├── 2.imageset
│ │ │ ├── 2.png
│ │ │ └── Contents.json
│ │ ├── 3.imageset
│ │ │ ├── 3.png
│ │ │ └── Contents.json
│ │ ├── 4.imageset
│ │ │ ├── 4.png
│ │ │ └── Contents.json
│ │ ├── 5.imageset
│ │ │ ├── 5.png
│ │ │ └── Contents.json
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ ├── close.imageset
│ │ │ ├── Contents.json
│ │ │ └── close@2x.png
│ │ └── home.imageset
│ │ │ ├── Contents.json
│ │ │ └── home.jpg
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── CellModel.h
│ ├── CellModel.m
│ ├── CollectionFirstSectionReusableView.h
│ ├── CollectionFirstSectionReusableView.m
│ ├── CollectionReusableView.h
│ ├── CollectionReusableView.m
│ ├── CollectionViewCell.h
│ ├── CollectionViewCell.m
│ ├── Info.plist
│ ├── SecondViewController.h
│ ├── SecondViewController.m
│ ├── SecondViewController.xib
│ ├── SectionModel.h
│ ├── SectionModel.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── CollectionView-nibTests
│ ├── CollectionView_nibTests.m
│ └── Info.plist
└── CollectionView-nibUITests
│ ├── CollectionView_nibUITests.m
│ └── Info.plist
└── 纯代码实现CollectionView
└── CollectionView-PureCode
├── .gitignore
├── CollectionView-PureCode.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── chenyufeng.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ └── chenyufeng.xcuserdatad
│ └── xcschemes
│ ├── CollectionView-PureCode.xcscheme
│ └── xcschememanagement.plist
├── CollectionView-PureCode
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
│ ├── 1.imageset
│ │ ├── 1.png
│ │ └── Contents.json
│ ├── 2.imageset
│ │ ├── 2.png
│ │ └── Contents.json
│ ├── 3.imageset
│ │ ├── 3.png
│ │ └── Contents.json
│ ├── 4.imageset
│ │ ├── 4.png
│ │ └── Contents.json
│ ├── 5.imageset
│ │ ├── 5.png
│ │ └── Contents.json
│ ├── 6.imageset
│ │ ├── 6.png
│ │ └── Contents.json
│ ├── 7.imageset
│ │ ├── 7.png
│ │ └── Contents.json
│ ├── 8.imageset
│ │ ├── 8.png
│ │ └── Contents.json
│ ├── 9.imageset
│ │ ├── 9.png
│ │ └── Contents.json
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ └── Contents.json
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── CollectionReusableView.h
├── CollectionReusableView.m
├── CollectionViewCell.h
├── CollectionViewCell.m
├── Info.plist
├── ViewController.h
├── ViewController.m
└── main.m
├── CollectionView-PureCodeTests
├── CollectionView_PureCodeTests.m
└── Info.plist
└── CollectionView-PureCodeUITests
├── CollectionView_PureCodeUITests.m
└── Info.plist
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.xcuserstate
3 | *.xcscheme
4 |
5 |
6 | build/
7 | DerivedData
8 |
9 | *.pbxuser
10 | !default.pbxuser
11 | *.mode1v3
12 | !default.mode1v3
13 | *.mode2v3
14 | !default.mode2v3
15 | *.perspectivev3
16 | !default.perspectivev3
17 | xcuserdata
18 |
19 | *.xccheckout
20 | *.moved-aside
21 |
22 |
23 |
24 | .AppleDouble
25 | .LSOverride
26 |
27 |
28 | .DocumentRevisions-V100
29 | .fseventsd
30 | .Spotlight-V100
31 | .TemporaryItems
32 | .Trashes
33 | .VolumeIcon.icns
34 |
35 |
36 | .AppleDB
37 | .AppleDesktop
38 | Network Trash Folder
39 | Temporary Items
40 | .apdisk
41 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.xcuserstate
3 | *.xcscheme
4 |
5 |
6 | build/
7 | DerivedData
8 |
9 | *.pbxuser
10 | !default.pbxuser
11 | *.mode1v3
12 | !default.mode1v3
13 | *.mode2v3
14 | !default.mode2v3
15 | *.perspectivev3
16 | !default.perspectivev3
17 | xcuserdata
18 |
19 | *.xccheckout
20 | *.moved-aside
21 |
22 |
23 |
24 | .AppleDouble
25 | .LSOverride
26 |
27 |
28 | .DocumentRevisions-V100
29 | .fseventsd
30 | .Spotlight-V100
31 | .TemporaryItems
32 | .Trashes
33 | .VolumeIcon.icns
34 |
35 |
36 | .AppleDB
37 | .AppleDesktop
38 | Network Trash Folder
39 | Temporary Items
40 | .apdisk
41 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
17 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
18 |
19 | return YES;
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/0.imageset/0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/0.imageset/0.png
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/0.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "0.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/1.imageset/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/1.imageset/1.png
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/1.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "1.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/2.imageset/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/2.imageset/2.png
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/2.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "2.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/3.imageset/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/3.imageset/3.png
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/3.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "3.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/4.imageset/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/4.imageset/4.png
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/4.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "4.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/5.imageset/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/5.imageset/5.png
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/5.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "5.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/home.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "home.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/home.imageset/home.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——Cell长按事件/CollectionView-nib/Assets.xcassets/home.imageset/home.jpg
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/CollectionReusableView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionReusableView.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionReusableView : UICollectionReusableView
12 |
13 | @property(strong,nonatomic)UILabel *title;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/CollectionReusableView.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // CollectionReusableView.m
4 | // CollectionView-nib
5 | //
6 | // Created by chenyufeng on 15/10/30.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "CollectionReusableView.h"
11 | #define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
12 | #define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
13 |
14 | @implementation CollectionReusableView
15 |
16 | - (instancetype)initWithFrame:(CGRect)frame{
17 |
18 | self = [super initWithFrame:frame];
19 | if (self) {
20 |
21 | self.title = [[UILabel alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT / 20, SCREEN_WIDTH, SCREEN_HEIGHT / 20)];
22 | self.title.textColor = [UIColor blackColor];
23 | self.title.textAlignment = NSTextAlignmentCenter;
24 | [self addSubview:self.title];
25 | }
26 | return self;
27 | }
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/CollectionViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionViewCell : UICollectionViewCell
12 |
13 | //每一个cell就是一个UIView,一个cell里面包含了一个图片和文本;
14 | //@property(nonatomic,strong)UIView *cellView;
15 | @property(strong,nonatomic) UIButton *imageButton;
16 | @property(strong,nonatomic) UILabel *descLabel;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/CollectionViewCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "CollectionViewCell.h"
10 |
11 | #define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
12 | #define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
13 |
14 | @implementation CollectionViewCell
15 |
16 | - (instancetype)initWithFrame:(CGRect)frame{
17 |
18 | self = [super initWithFrame:frame];
19 | if (self) {
20 | //这里需要初始化ImageView;
21 | self.imageButton = [[UIButton alloc] initWithFrame:CGRectMake((self.bounds.size.width - 32) / 2, (self.bounds.size.width - 32) / 2, 32, 32)];
22 | self.imageButton.tag = 100;
23 | self.descLabel = [[UILabel alloc] initWithFrame:CGRectMake((self.bounds.size.width - 100) / 2, (self.bounds.size.width - 32) / 2 + 30, 100, 20)];
24 | self.descLabel.textAlignment = NSTextAlignmentCenter;
25 | self.descLabel.font=[UIFont systemFontOfSize:10];
26 | self.descLabel.tag = 101;
27 |
28 | [self.contentView addSubview:self.imageButton];
29 | [self.contentView addSubview:self.descLabel];
30 | }
31 | return self;
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/SecondViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SecondViewController.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SecondViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/SecondViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 | @end
14 |
15 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "SecondViewController.h"
11 |
12 | @interface ViewController ()
13 |
14 | @property(strong,nonatomic) UIButton *button;
15 |
16 | @end
17 |
18 | @implementation ViewController
19 |
20 | - (void)viewDidLoad {
21 |
22 | [super viewDidLoad];
23 | self.button = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 200, 20)];
24 | [self.button setTitle:@"跳转到CollectionView" forState:UIControlStateNormal];
25 | [self.button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
26 | [self.button setUserInteractionEnabled:true];
27 | [self.view addSubview:self.button];
28 |
29 | [self.button addTarget:self action:@selector(clickButton:) forControlEvents:(UIControlEventTouchUpInside)];
30 | }
31 |
32 | - (void)clickButton:(id)sender{
33 |
34 | [self presentViewController:[[SecondViewController alloc] init] animated:true completion:^{
35 | //跳转完成后执行的操作;
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nib/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nibTests/CollectionView_nibTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionView_nibTests.m
3 | // CollectionView-nibTests
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionView_nibTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CollectionView_nibTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nibTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nibUITests/CollectionView_nibUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionView_nibUITests.m
3 | // CollectionView-nibUITests
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionView_nibUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CollectionView_nibUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/CollectionView进阶——Cell长按事件/CollectionView-nibUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.xcuserstate
3 | *.xcscheme
4 |
5 |
6 | build/
7 | DerivedData
8 |
9 | *.pbxuser
10 | !default.pbxuser
11 | *.mode1v3
12 | !default.mode1v3
13 | *.mode2v3
14 | !default.mode2v3
15 | *.perspectivev3
16 | !default.perspectivev3
17 | xcuserdata
18 |
19 | *.xccheckout
20 | *.moved-aside
21 |
22 |
23 |
24 | .AppleDouble
25 | .LSOverride
26 |
27 |
28 | .DocumentRevisions-V100
29 | .fseventsd
30 | .Spotlight-V100
31 | .TemporaryItems
32 | .Trashes
33 | .VolumeIcon.icns
34 |
35 |
36 | .AppleDB
37 | .AppleDesktop
38 | Network Trash Folder
39 | Temporary Items
40 | .apdisk
41 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
17 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
18 | // Override point for customization after application launch.
19 | return YES;
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/0.imageset/0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/0.imageset/0.png
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/0.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "0.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/1.imageset/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/1.imageset/1.png
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/1.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "1.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/2.imageset/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/2.imageset/2.png
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/2.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "2.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/3.imageset/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/3.imageset/3.png
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/3.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "3.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/4.imageset/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/4.imageset/4.png
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/4.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "4.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/5.imageset/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/5.imageset/5.png
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/5.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "5.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/home.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "home.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/home.imageset/home.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Assets.xcassets/home.imageset/home.jpg
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/CollectionReusableView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionReusableView.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionReusableView : UICollectionReusableView
12 |
13 | @property(strong,nonatomic)UILabel *title;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/CollectionReusableView.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // CollectionReusableView.m
4 | // CollectionView-nib
5 | //
6 | // Created by chenyufeng on 15/10/30.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "CollectionReusableView.h"
11 | #define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
12 | #define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
13 |
14 | @implementation CollectionReusableView
15 |
16 | - (instancetype)initWithFrame:(CGRect)frame{
17 |
18 | self = [super initWithFrame:frame];
19 | if (self) {
20 |
21 | self.title = [[UILabel alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT / 20, SCREEN_WIDTH, SCREEN_HEIGHT / 20)];
22 | self.title.textColor = [UIColor blackColor];
23 | self.title.textAlignment = NSTextAlignmentCenter;
24 | [self addSubview:self.title];
25 | }
26 | return self;
27 | }
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/CollectionViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionViewCell : UICollectionViewCell
12 |
13 | //每一个cell就是一个UIView,一个cell里面包含了一个图片和文本;
14 | //@property(nonatomic,strong)UIView *cellView;
15 | @property(strong,nonatomic) UIButton *imageButton;
16 | @property(strong,nonatomic) UILabel *descLabel;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/CollectionViewCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "CollectionViewCell.h"
10 |
11 | #define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
12 | #define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
13 |
14 | @implementation CollectionViewCell
15 |
16 | - (instancetype)initWithFrame:(CGRect)frame{
17 |
18 | self = [super initWithFrame:frame];
19 | if (self) {
20 | //这里需要初始化ImageView;
21 | self.imageButton = [[UIButton alloc] initWithFrame:CGRectMake((self.bounds.size.width - 32) / 2, (self.bounds.size.width - 32) / 2, 32, 32)];
22 | self.imageButton.tag = 100;
23 | self.descLabel = [[UILabel alloc] initWithFrame:CGRectMake((self.bounds.size.width - 100) / 2, (self.bounds.size.width - 32) / 2 + 30, 100, 20)];
24 | self.descLabel.textAlignment = NSTextAlignmentCenter;
25 | self.descLabel.font=[UIFont systemFontOfSize:10];
26 | self.descLabel.tag = 101;
27 |
28 | [self.contentView addSubview:self.imageButton];
29 | [self.contentView addSubview:self.descLabel];
30 | }
31 | return self;
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/SecondViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SecondViewController.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SecondViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/SecondViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 | @end
14 |
15 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "SecondViewController.h"
11 |
12 | @interface ViewController ()
13 |
14 | @property(strong,nonatomic) UIButton *button;
15 |
16 | @end
17 |
18 | @implementation ViewController
19 |
20 | - (void)viewDidLoad {
21 |
22 | [super viewDidLoad];
23 | self.button = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 200, 20)];
24 | [self.button setTitle:@"跳转到CollectionView" forState:UIControlStateNormal];
25 | [self.button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
26 | [self.button setUserInteractionEnabled:true];
27 | [self.view addSubview:self.button];
28 |
29 | [self.button addTarget:self action:@selector(clickButton:) forControlEvents:(UIControlEventTouchUpInside)];
30 | }
31 |
32 | - (void)clickButton:(id)sender{
33 |
34 | [self presentViewController:[[SecondViewController alloc] init] animated:true completion:^{
35 | //跳转完成后执行的操作;
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nib/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nibTests/CollectionView_nibTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionView_nibTests.m
3 | // CollectionView-nibTests
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionView_nibTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CollectionView_nibTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nibTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nibUITests/CollectionView_nibUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionView_nibUITests.m
3 | // CollectionView-nibUITests
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionView_nibUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CollectionView_nibUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/CollectionView进阶——获取Cell中按钮点击事件/CollectionView-nibUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CollectionView
2 | 这里我在iOS中使用三种不同的方式实现UICollectionView,也就是一种瀑布流视图。分别使用storyboard、nib和纯代码的方式来实现。
3 | ##1.项目说明
4 | UICollectionView继承自UITableView,基本的实现方式同UITableView。用UICollectionView实现的视图就是所谓的瀑布流界面,很多的电商网站,图片浏览App都是采用了这种设计方式。在我的这个项目中,我分别使用三种不同的方式来实现CollectionView:storyboard、nib文件和纯代码,可以适用在多种不同的项目开发情境下。
5 | ##2.动态加载
6 | 我在第四个例子中实现了使用UICollectionView进行动态增加一个Cell或者Section,主要使用了Lazy Load懒加载进行。并在插入一个Section的时候动态编辑Header头部视图。
7 | ##3.实现效果
8 | 
9 |
10 | 动态增加Cell和Section的效果如下:
11 | 
12 |
13 | 
14 |
15 | 
16 |
17 |
18 |
19 | ##4.技术博客
20 | 我的个人技术博客:[http://blog.csdn.net/chenyufeng1991](http://blog.csdn.net/chenyufeng1991) 。欢迎大家访问!
--------------------------------------------------------------------------------
/Screenshots/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Screenshots/1.png
--------------------------------------------------------------------------------
/Screenshots/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Screenshots/2.png
--------------------------------------------------------------------------------
/Screenshots/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Screenshots/3.png
--------------------------------------------------------------------------------
/Screenshots/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Screenshots/4.png
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.xcuserstate
3 | *.xcscheme
4 |
5 |
6 | build/
7 | DerivedData
8 |
9 | *.pbxuser
10 | !default.pbxuser
11 | *.mode1v3
12 | !default.mode1v3
13 | *.mode2v3
14 | !default.mode2v3
15 | *.perspectivev3
16 | !default.perspectivev3
17 | xcuserdata
18 |
19 | *.xccheckout
20 | *.moved-aside
21 |
22 |
23 |
24 | .AppleDouble
25 | .LSOverride
26 |
27 |
28 | .DocumentRevisions-V100
29 | .fseventsd
30 | .Spotlight-V100
31 | .TemporaryItems
32 | .Trashes
33 | .VolumeIcon.icns
34 |
35 |
36 | .AppleDB
37 | .AppleDesktop
38 | Network Trash Folder
39 | Temporary Items
40 | .apdisk
41 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard.xcodeproj/project.xcworkspace/xcuserdata/chenyufeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard.xcodeproj/project.xcworkspace/xcuserdata/chenyufeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard.xcodeproj/xcuserdata/chenyufeng.xcuserdatad/xcschemes/CollectionView-Storyboard.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
43 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
74 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
95 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard.xcodeproj/xcuserdata/chenyufeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CollectionView-Storyboard.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 714576C01BE25FAA0072DC03
16 |
17 | primary
18 |
19 |
20 | 714576D91BE25FAA0072DC03
21 |
22 | primary
23 |
24 |
25 | 714576E41BE25FAA0072DC03
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CollectionView-Storyboard
4 | //
5 | // Created by chenyufeng on 15/10/29.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 | //这里写一个全局变量,计算屏幕的宽度;
11 | #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
12 |
13 | @interface AppDelegate : UIResponder
14 |
15 | @property (strong, nonatomic) UIWindow *window;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CollectionView-Storyboard
4 | //
5 | // Created by chenyufeng on 15/10/29.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
18 | // Override point for customization after application launch.
19 | return YES;
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/1.imageset/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/1.imageset/1.png
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/1.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "1.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/2.imageset/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/2.imageset/2.png
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/2.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "2.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/3.imageset/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/3.imageset/3.png
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/3.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "3.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/4.imageset/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/4.imageset/4.png
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/4.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "4.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/5.imageset/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/5.imageset/5.png
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/5.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "5.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/6.imageset/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/6.imageset/6.png
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/6.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "6.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/7.imageset/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/7.imageset/7.png
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/7.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "7.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/8.imageset/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/8.imageset/8.png
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/8.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "8.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/9.imageset/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/9.imageset/9.png
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/9.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "9.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/close.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "close@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/close.imageset/close@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Assets.xcassets/close.imageset/close@2x.png
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/CollectionReusableView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionReusableView.h
3 | // CollectionView-Storyboard
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionReusableView : UICollectionReusableView
12 |
13 | @property(strong,nonatomic)UILabel *title;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/CollectionReusableView.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // CollectionReusableView.m
4 | // CollectionView-Storyboard
5 | //
6 | // Created by chenyufeng on 15/10/30.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "CollectionReusableView.h"
11 |
12 | @implementation CollectionReusableView
13 |
14 | - (instancetype)initWithFrame:(CGRect)frame{
15 |
16 | self = [super initWithFrame:frame];
17 | if (self) {
18 |
19 | self.title = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 20)];
20 | self.title.textColor = [UIColor blackColor];
21 | [self addSubview:self.title];
22 | }
23 | return self;
24 | }
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/CollectionViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.h
3 | // CollectionView-Storyboard
4 | //
5 | // Created by chenyufeng on 15/10/29.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionViewCell : UICollectionViewCell
12 |
13 | @property (weak, nonatomic) IBOutlet UIImageView *imageView;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/CollectionViewCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.m
3 | // CollectionView-Storyboard
4 | //
5 | // Created by chenyufeng on 15/10/29.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "CollectionViewCell.h"
10 | #import "AppDelegate.h"
11 |
12 | @implementation CollectionViewCell
13 |
14 | - (instancetype)initWithFrame:(CGRect)frame{
15 |
16 | self = [super initWithFrame:frame];
17 | if (self) {
18 | //initial;
19 | //在这里我设置图片的大小,我设置成正方形;
20 | self.imageView.frame = CGRectMake(0, 0, (SCREEN_WIDTH - 80)/3, (SCREEN_WIDTH - 80)/3);
21 | }
22 | return self;
23 | }
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CollectionView-Storyboard
4 | //
5 | // Created by chenyufeng on 15/10/29.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 | @end
14 |
15 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // CollectionView-Storyboard
4 | //
5 | // Created by chenyufeng on 15/10/29.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "CollectionViewCell.h"
11 | #import "AppDelegate.h"
12 | #import "CollectionReusableView.h"
13 |
14 | @interface ViewController ()
15 |
16 | @property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
17 | @property(strong,nonatomic) NSMutableArray *arr;
18 | @property(strong,nonatomic)CollectionReusableView *header;
19 |
20 | @end
21 |
22 | @implementation ViewController
23 |
24 | - (void)viewDidLoad {
25 |
26 | [super viewDidLoad];
27 | self.arr = [[NSMutableArray alloc] initWithCapacity:10];
28 | for (int i = 0 ; i < 9; i++) {
29 | [self.arr addObject:[UIImage imageNamed:[[NSString alloc] initWithFormat:@"%d",i + 1]]];
30 | }
31 | [self.collectionView registerClass:[CollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"Reusable"];
32 | }
33 |
34 | #pragma mark - UICollectionViewDataSource
35 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
36 | return self.arr.count;
37 | }
38 |
39 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
40 |
41 | NSString *collectionCellIdentifier = @"MyCollectionCell";
42 | CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:collectionCellIdentifier forIndexPath:indexPath];
43 | cell.imageView.image = [self.arr objectAtIndex:indexPath.row];
44 | return cell;
45 | }
46 |
47 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
48 | return 3;
49 | }
50 |
51 | // The view that is returned must be retrieved from a call to -dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath:
52 | - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
53 |
54 | UICollectionReusableView *reusableView = nil;
55 | if (kind == UICollectionElementKindSectionHeader) {
56 | self.header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"Reusable" forIndexPath:indexPath];
57 | self.header.title.text = [[NSString alloc] initWithFormat:@"头部视图%ld",(long)indexPath.section ];
58 |
59 | reusableView = self.header;
60 | }
61 | return reusableView;
62 | }
63 |
64 | #pragma mark - UICollectionViewDelegate
65 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
66 | NSLog(@"第%ld个section,第%ld个cell被点击了",(long)indexPath.section,(long)indexPath.row);
67 | }
68 |
69 | #pragma mark - UICollectionViewDelegateFlowLayout
70 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
71 | return CGSizeMake((SCREEN_WIDTH - 80) / 3, (SCREEN_WIDTH - 80) / 3);
72 | }
73 |
74 | - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
75 | return UIEdgeInsetsMake(0, 10, 10, 10);
76 | }
77 |
78 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
79 | return 10;
80 | }
81 |
82 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
83 | return 10;
84 | }
85 |
86 | //下面的回调是必须的;
87 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
88 | return CGSizeMake(200, 20);
89 | }
90 |
91 | @end
92 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-Storyboard/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CollectionView-Storyboard
4 | //
5 | // Created by chenyufeng on 15/10/29.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-StoryboardTests/CollectionView_StoryboardTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionView_StoryboardTests.m
3 | // CollectionView-StoryboardTests
4 | //
5 | // Created by chenyufeng on 15/10/29.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionView_StoryboardTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CollectionView_StoryboardTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-StoryboardTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-StoryboardUITests/CollectionView_StoryboardUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionView_StoryboardUITests.m
3 | // CollectionView-StoryboardUITests
4 | //
5 | // Created by chenyufeng on 15/10/29.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionView_StoryboardUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CollectionView_StoryboardUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/Storyboard实现CollectionView/CollectionView-Storyboard/CollectionView-StoryboardUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.xcuserstate
3 | *.xcscheme
4 |
5 |
6 | build/
7 | DerivedData
8 |
9 | *.pbxuser
10 | !default.pbxuser
11 | *.mode1v3
12 | !default.mode1v3
13 | *.mode2v3
14 | !default.mode2v3
15 | *.perspectivev3
16 | !default.perspectivev3
17 | xcuserdata
18 |
19 | *.xccheckout
20 | *.moved-aside
21 |
22 |
23 |
24 | .AppleDouble
25 | .LSOverride
26 |
27 |
28 | .DocumentRevisions-V100
29 | .fseventsd
30 | .Spotlight-V100
31 | .TemporaryItems
32 | .Trashes
33 | .VolumeIcon.icns
34 |
35 |
36 | .AppleDB
37 | .AppleDesktop
38 | Network Trash Folder
39 | Temporary Items
40 | .apdisk
41 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib.xcodeproj/project.xcworkspace/xcuserdata/chenyufeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/nib实现CollectionView/CollectionView-nib/CollectionView-nib.xcodeproj/project.xcworkspace/xcuserdata/chenyufeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib.xcodeproj/xcuserdata/chenyufeng.xcuserdatad/xcschemes/CollectionView-nib.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
43 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
74 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
95 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib.xcodeproj/xcuserdata/chenyufeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CollectionView-nib.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 710589DF1BE2FE5B00D13C07
16 |
17 | primary
18 |
19 |
20 | 710589F81BE2FE5B00D13C07
21 |
22 | primary
23 |
24 |
25 | 71058A031BE2FE5B00D13C07
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
17 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
18 | // Override point for customization after application launch.
19 | return YES;
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/1.imageset/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/1.imageset/1.png
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/1.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "1.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/2.imageset/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/2.imageset/2.png
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/2.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "2.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/3.imageset/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/3.imageset/3.png
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/3.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "3.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/4.imageset/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/4.imageset/4.png
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/4.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "4.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/5.imageset/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/5.imageset/5.png
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/5.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "5.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/6.imageset/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/6.imageset/6.png
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/6.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "6.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/7.imageset/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/7.imageset/7.png
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/7.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "7.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/8.imageset/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/8.imageset/8.png
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/8.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "8.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/9.imageset/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/9.imageset/9.png
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/9.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "9.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/CollectionReusableView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionReusableView.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionReusableView : UICollectionReusableView
12 |
13 | @property(strong,nonatomic)UILabel *title;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/CollectionReusableView.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // CollectionReusableView.m
4 | // CollectionView-nib
5 | //
6 | // Created by chenyufeng on 15/10/30.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "CollectionReusableView.h"
11 |
12 | @implementation CollectionReusableView
13 |
14 | - (instancetype)initWithFrame:(CGRect)frame{
15 |
16 | self = [super initWithFrame:frame];
17 | if (self) {
18 |
19 | self.title = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, 300, 20)];
20 | self.title.textColor = [UIColor blackColor];
21 | [self addSubview:self.title];
22 | }
23 | return self;
24 | }
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/CollectionViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionViewCell : UICollectionViewCell
12 |
13 | @property(strong,nonatomic) UIImageView *imageView;
14 | @property(strong,nonatomic) UILabel *descLabel;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/CollectionViewCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "CollectionViewCell.h"
10 |
11 | #define UISCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
12 |
13 | @implementation CollectionViewCell
14 |
15 | - (instancetype)initWithFrame:(CGRect)frame{
16 |
17 | self = [super initWithFrame:frame];
18 | if (self) {
19 | //这里需要初始化ImageView;
20 | self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, (UISCREEN_WIDTH - 80) / 3, (UISCREEN_WIDTH - 80) / 3)];
21 | [self addSubview:self.imageView];
22 | [self.imageView setUserInteractionEnabled:true];
23 |
24 | self.descLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, (UISCREEN_WIDTH - 80) / 3, (UISCREEN_WIDTH - 80) / 3, 20)];
25 | self.descLabel.textAlignment = NSTextAlignmentCenter;
26 | [self addSubview:self.descLabel];
27 | }
28 | return self;
29 | }
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/SecondViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SecondViewController.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SecondViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/SecondViewController.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // SecondViewController.m
4 | // CollectionView-nib
5 | //
6 | // Created by chenyufeng on 15/10/30.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "SecondViewController.h"
11 | #import "CollectionViewCell.h"
12 | #import "AppDelegate.h"
13 | #import "CollectionReusableView.h"
14 |
15 | #define UISCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
16 |
17 | @interface SecondViewController ()
18 |
19 | @property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
20 | @property (strong,nonatomic) NSMutableArray *arr;
21 |
22 | @end
23 |
24 | @implementation SecondViewController
25 |
26 | - (void)viewDidLoad {
27 |
28 | [super viewDidLoad];
29 | //进行CollectionView和Cell的绑定
30 | [self.collectionView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:@"CollectionCell"];
31 | self.collectionView.backgroundColor = [UIColor whiteColor];
32 |
33 | self.arr = [[NSMutableArray alloc] initWithCapacity:10];
34 | for (int i = 0; i < 9; i++) {
35 | [self.arr addObject:[UIImage imageNamed:[NSString stringWithFormat:@"%d",i + 1]]];
36 | }
37 | //千万不要忘了设置delegate
38 | self.collectionView.delegate = self;
39 | self.collectionView.dataSource = self;
40 |
41 | //注册CollectionReusableView;
42 | [self.collectionView registerClass:[CollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"Header"];
43 | }
44 |
45 | #pragma mark - UICollectionViewDataSource
46 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
47 | return self.arr.count;
48 | }
49 |
50 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
51 |
52 | CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCell" forIndexPath:indexPath];
53 | cell.imageView.image = [self.arr objectAtIndex:indexPath.row];
54 | cell.descLabel.text = [[NSString alloc] initWithFormat:@"{%ld,%ld}",indexPath.section,indexPath.row];
55 | return cell;
56 | }
57 |
58 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
59 | return 3;
60 | }
61 |
62 | - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
63 |
64 | UICollectionReusableView *reusable = nil;
65 | if (kind == UICollectionElementKindSectionHeader) {
66 | CollectionReusableView *view = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"Header" forIndexPath:indexPath];
67 |
68 | view.title.text = [[NSString alloc] initWithFormat:@"头部视图%ld",indexPath.section];
69 | reusable = view;
70 | }
71 | return reusable;
72 | }
73 |
74 | #pragma mark - UICollectionViewDelegate
75 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
76 |
77 | NSString *message = [[NSString alloc] initWithFormat:@"您点击第%ld个section,第%ld个cell",(long)indexPath.section,(long)indexPath.row];
78 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:message preferredStyle:UIAlertControllerStyleAlert];
79 | [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
80 | //点击确定按钮后的响应事件;
81 | }]];
82 | [self presentViewController:alert animated:true completion:^{
83 | //显示提示框后执行的事件;
84 | }];
85 | }
86 |
87 | #pragma mark - UICollectionViewDelegateFlowLayout
88 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
89 | return CGSizeMake((UISCREEN_WIDTH - 80) / 3, (UISCREEN_WIDTH - 80) / 3 + 20);
90 | }
91 |
92 | - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
93 | return UIEdgeInsetsMake(10,20,10,20);
94 | }
95 |
96 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
97 | return CGSizeMake(self.collectionView.frame.size.width, 50);
98 | }
99 |
100 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
101 | return 1.f;
102 | }
103 |
104 | @end
105 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/SecondViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 | @end
14 |
15 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "SecondViewController.h"
11 |
12 | @interface ViewController ()
13 |
14 | @property(strong,nonatomic) UIButton *button;
15 |
16 | @end
17 |
18 | @implementation ViewController
19 |
20 | - (void)viewDidLoad {
21 |
22 | [super viewDidLoad];
23 | self.button = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 200, 20)];
24 | [self.button setTitle:@"跳转到CollectionView" forState:UIControlStateNormal];
25 | [self.button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
26 | [self.button setUserInteractionEnabled:true];
27 | [self.view addSubview:self.button];
28 |
29 | [self.button addTarget:self action:@selector(clickButton:) forControlEvents:(UIControlEventTouchUpInside)];
30 | }
31 |
32 | - (void)clickButton:(id)sender{
33 |
34 | [self presentViewController:[[SecondViewController alloc] init] animated:true completion:^{
35 | //跳转完成后执行的操作;
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nib/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nibTests/CollectionView_nibTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionView_nibTests.m
3 | // CollectionView-nibTests
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionView_nibTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CollectionView_nibTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nibTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nibUITests/CollectionView_nibUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionView_nibUITests.m
3 | // CollectionView-nibUITests
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionView_nibUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CollectionView_nibUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/nib实现CollectionView/CollectionView-nib/CollectionView-nibUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.xcuserstate
3 | *.xcscheme
4 |
5 |
6 | build/
7 | DerivedData
8 |
9 | *.pbxuser
10 | !default.pbxuser
11 | *.mode1v3
12 | !default.mode1v3
13 | *.mode2v3
14 | !default.mode2v3
15 | *.perspectivev3
16 | !default.perspectivev3
17 | xcuserdata
18 |
19 | *.xccheckout
20 | *.moved-aside
21 |
22 |
23 |
24 | .AppleDouble
25 | .LSOverride
26 |
27 |
28 | .DocumentRevisions-V100
29 | .fseventsd
30 | .Spotlight-V100
31 | .TemporaryItems
32 | .Trashes
33 | .VolumeIcon.icns
34 |
35 |
36 | .AppleDB
37 | .AppleDesktop
38 | Network Trash Folder
39 | Temporary Items
40 | .apdisk
41 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
17 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
18 | // Override point for customization after application launch.
19 | return YES;
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/0.imageset/0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/0.imageset/0.png
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/0.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "0.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/1.imageset/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/1.imageset/1.png
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/1.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "1.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/2.imageset/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/2.imageset/2.png
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/2.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "2.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/3.imageset/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/3.imageset/3.png
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/3.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "3.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/4.imageset/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/4.imageset/4.png
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/4.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "4.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/5.imageset/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/5.imageset/5.png
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/5.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "5.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/close.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "close@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/close.imageset/close@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/close.imageset/close@2x.png
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/home.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "home.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/home.imageset/home.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/动态增加cell和section实现/CollectionView-nib/Assets.xcassets/home.imageset/home.jpg
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/CellModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // CellModel.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/12/1.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CellModel : NSObject
12 |
13 | //定义cell中的图片;
14 | @property(nonatomic,strong) NSString *cellImage;
15 | //定义cell中的描述文字;
16 | @property(nonatomic,strong) NSString *cellDesc;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/CellModel.m:
--------------------------------------------------------------------------------
1 | //
2 | // CellModel.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/12/1.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "CellModel.h"
10 |
11 | @implementation CellModel
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/CollectionFirstSectionReusableView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionFirstSectionReusableView.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/11/24.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionFirstSectionReusableView : UICollectionReusableView
12 |
13 | @property(strong,nonatomic)UILabel *title;
14 | @property(strong,nonatomic)UIImageView *imageView;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/CollectionFirstSectionReusableView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionFirstSectionReusableView.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/11/24.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "CollectionFirstSectionReusableView.h"
10 |
11 | #define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
12 | #define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
13 |
14 | @implementation CollectionFirstSectionReusableView
15 |
16 |
17 | - (instancetype)initWithFrame:(CGRect)frame
18 | {
19 | self = [super initWithFrame:frame];
20 | if (self) {
21 |
22 | self.title = [[UILabel alloc] initWithFrame:CGRectMake(0, 155, SCREEN_WIDTH, 20)];
23 | self.title.textColor = [UIColor blackColor];
24 | self.title.textAlignment = NSTextAlignmentCenter;
25 |
26 |
27 |
28 | self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 150)];
29 | [self.imageView setImage:[UIImage imageNamed:@"home"]];
30 |
31 |
32 |
33 |
34 | [self addSubview:self.title];
35 | [self addSubview:self.imageView];
36 |
37 |
38 | }
39 | return self;
40 | }
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/CollectionReusableView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionReusableView.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionReusableView : UICollectionReusableView
12 |
13 | @property(strong,nonatomic)UILabel *title;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/CollectionReusableView.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // CollectionReusableView.m
4 | // CollectionView-nib
5 | //
6 | // Created by chenyufeng on 15/10/30.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "CollectionReusableView.h"
11 |
12 | @implementation CollectionReusableView
13 |
14 | - (instancetype)initWithFrame:(CGRect)frame{
15 |
16 | self = [super initWithFrame:frame];
17 | if (self) {
18 |
19 | self.title = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, [[UIScreen mainScreen] bounds].size.width, 20)];
20 | self.title.textColor = [UIColor blackColor];
21 | self.title.textAlignment = NSTextAlignmentCenter;
22 | [self addSubview:self.title];
23 | }
24 | return self;
25 | }
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/CollectionViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionViewCell : UICollectionViewCell
12 |
13 | //cell中的图片;
14 | @property(strong,nonatomic) UIImageView *imageView;
15 | //cell中的描述文本;
16 | @property(strong,nonatomic) UILabel *descLabel;
17 | //cell右上角的删除按钮;
18 | @property(nonatomic,strong)UIButton *deleteButton;
19 | @end
20 |
21 |
22 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/CollectionViewCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "CollectionViewCell.h"
10 |
11 | #define UISCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
12 | #define CELL_WIDTH (([[UIScreen mainScreen] bounds].size.width - 40) / 3)
13 |
14 | @implementation CollectionViewCell
15 |
16 | - (instancetype)initWithFrame:(CGRect)frame{
17 |
18 | self = [super initWithFrame:frame];
19 | if (self) {
20 | //这里需要初始化ImageView;
21 | self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width - (UISCREEN_WIDTH - 40) / 6 - 20, self.frame.size.width-(UISCREEN_WIDTH - 40) / 6 - 20, 40, 40)];
22 | [self.imageView setUserInteractionEnabled:true];
23 | self.descLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.frame.size.width - (UISCREEN_WIDTH - 40) / 6 + 20, (UISCREEN_WIDTH - 40) / 3, 20)];
24 | self.descLabel.textAlignment = NSTextAlignmentCenter;
25 | self.descLabel.text = @"111";
26 | self.deleteButton = [[UIButton alloc] initWithFrame:CGRectMake(CELL_WIDTH - 35, 5, 30, 30)];
27 | [self.deleteButton setImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
28 | //先设置不可见;
29 | [self.deleteButton setHidden:true];
30 |
31 | self.layer.borderWidth = 0.5;
32 |
33 | [self addSubview:self.imageView];
34 | [self addSubview:self.descLabel];
35 | [self addSubview:self.deleteButton];
36 | }
37 | return self;
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/SecondViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SecondViewController.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SecondViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/SecondViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
42 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/SectionModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // SectionModel.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/11/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SectionModel : NSObject
12 |
13 | //定义Section头的名字;
14 | @property(nonatomic,copy) NSString *sectionName;
15 | //定义Section中的cell数组;
16 | @property(nonatomic,strong) NSMutableArray *cellArray;//这里存放的是section中的每一个cell;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/SectionModel.m:
--------------------------------------------------------------------------------
1 | //
2 | // SectionModel.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/11/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "SectionModel.h"
10 |
11 | @implementation SectionModel
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 | @end
14 |
15 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "SecondViewController.h"
11 |
12 | @interface ViewController ()
13 |
14 | @property(strong,nonatomic) UIButton *button;
15 |
16 | @end
17 |
18 | @implementation ViewController
19 |
20 | - (void)viewDidLoad {
21 |
22 | [super viewDidLoad];
23 | self.button = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 200, 20)];
24 | [self.button setTitle:@"跳转到CollectionView" forState:UIControlStateNormal];
25 | [self.button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
26 | [self.button setUserInteractionEnabled:true];
27 | [self.view addSubview:self.button];
28 |
29 | [self.button addTarget:self action:@selector(clickButton:) forControlEvents:(UIControlEventTouchUpInside)];
30 | }
31 |
32 | - (void)clickButton:(id)sender{
33 |
34 | [self presentViewController:[[SecondViewController alloc] init] animated:true completion:^{
35 | //跳转完成后执行的操作;
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nib/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CollectionView-nib
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nibTests/CollectionView_nibTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionView_nibTests.m
3 | // CollectionView-nibTests
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionView_nibTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CollectionView_nibTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nibTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nibUITests/CollectionView_nibUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionView_nibUITests.m
3 | // CollectionView-nibUITests
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionView_nibUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CollectionView_nibUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/动态增加cell和section实现/CollectionView-nibUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.xcuserstate
3 | *.xcscheme
4 |
5 |
6 | build/
7 | DerivedData
8 |
9 | *.pbxuser
10 | !default.pbxuser
11 | *.mode1v3
12 | !default.mode1v3
13 | *.mode2v3
14 | !default.mode2v3
15 | *.perspectivev3
16 | !default.perspectivev3
17 | xcuserdata
18 |
19 | *.xccheckout
20 | *.moved-aside
21 |
22 |
23 |
24 | .AppleDouble
25 | .LSOverride
26 |
27 |
28 | .DocumentRevisions-V100
29 | .fseventsd
30 | .Spotlight-V100
31 | .TemporaryItems
32 | .Trashes
33 | .VolumeIcon.icns
34 |
35 |
36 | .AppleDB
37 | .AppleDesktop
38 | Network Trash Folder
39 | Temporary Items
40 | .apdisk
41 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode.xcodeproj/project.xcworkspace/xcuserdata/chenyufeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode.xcodeproj/project.xcworkspace/xcuserdata/chenyufeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode.xcodeproj/xcuserdata/chenyufeng.xcuserdatad/xcschemes/CollectionView-PureCode.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
43 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
74 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
95 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode.xcodeproj/xcuserdata/chenyufeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CollectionView-PureCode.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 71058A261BE3156100D13C07
16 |
17 | primary
18 |
19 |
20 | 71058A3F1BE3156100D13C07
21 |
22 | primary
23 |
24 |
25 | 71058A4A1BE3156100D13C07
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CollectionView-PureCode
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CollectionView-PureCode
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // 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.
25 | // 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.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // 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.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // 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.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // 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.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/1.imageset/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/1.imageset/1.png
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/1.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "1.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/2.imageset/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/2.imageset/2.png
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/2.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "2.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/3.imageset/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/3.imageset/3.png
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/3.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "3.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/4.imageset/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/4.imageset/4.png
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/4.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "4.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/5.imageset/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/5.imageset/5.png
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/5.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "5.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/6.imageset/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/6.imageset/6.png
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/6.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "6.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/7.imageset/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/7.imageset/7.png
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/7.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "7.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/8.imageset/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/8.imageset/8.png
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/8.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "8.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/9.imageset/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyufeng1991/CollectionView/91d16470ed94d17dd4694cc2eb50d65f40721b0f/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/9.imageset/9.png
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/9.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "9.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/CollectionReusableView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionReusableView.h
3 | // CollectionView-PureCode
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionReusableView : UICollectionReusableView
12 |
13 | @property(strong,nonatomic)UILabel *title;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/CollectionReusableView.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // CollectionReusableView.m
4 | // CollectionView-PureCode
5 | //
6 | // Created by chenyufeng on 15/10/30.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "CollectionReusableView.h"
11 |
12 | @implementation CollectionReusableView
13 |
14 | - (instancetype)initWithFrame:(CGRect)frame{
15 |
16 | self = [super initWithFrame:frame];
17 | if (self) {
18 |
19 | self.title = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, 300, 20)];
20 | self.title.textColor = [UIColor blackColor];
21 | [self addSubview:self.title];
22 | }
23 | return self;
24 | }
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/CollectionViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.h
3 | // CollectionView-PureCode
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionViewCell : UICollectionViewCell
12 |
13 | @property(strong,nonatomic) UIImageView *imageView;
14 | @property(strong,nonatomic) UILabel *descLabel;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/CollectionViewCell.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // CollectionViewCell.m
4 | // CollectionView-PureCode
5 | //
6 | // Created by chenyufeng on 15/10/30.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "CollectionViewCell.h"
11 |
12 | #define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
13 |
14 | @implementation CollectionViewCell
15 |
16 | - (instancetype)initWithFrame:(CGRect)frame{
17 |
18 | self = [super initWithFrame:frame];
19 | if (self) {
20 |
21 | self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, (SCREEN_WIDTH - 80) / 3, (SCREEN_WIDTH - 80) / 3)];
22 | [self.imageView setUserInteractionEnabled:true];
23 | [self addSubview:self.imageView];
24 | self.descLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, (SCREEN_WIDTH - 80) / 3, (SCREEN_WIDTH - 80) / 3, 20)];
25 | self.descLabel.textAlignment = NSTextAlignmentCenter;
26 | [self addSubview:self.descLabel];
27 | }
28 | return self;
29 | }
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CollectionView-PureCode
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCode/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CollectionView-PureCode
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCodeTests/CollectionView_PureCodeTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionView_PureCodeTests.m
3 | // CollectionView-PureCodeTests
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionView_PureCodeTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CollectionView_PureCodeTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCodeTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCodeUITests/CollectionView_PureCodeUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionView_PureCodeUITests.m
3 | // CollectionView-PureCodeUITests
4 | //
5 | // Created by chenyufeng on 15/10/30.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionView_PureCodeUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CollectionView_PureCodeUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/纯代码实现CollectionView/CollectionView-PureCode/CollectionView-PureCodeUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------