Skip to content

Commit 4a56d8d

Browse files
authored
Merge pull request #14 from giulio92/develop
2 parents e8a867c + 9ec67f4 commit 4a56d8d

File tree

10 files changed

+143
-98
lines changed

10 files changed

+143
-98
lines changed

Classes/GLCollectionTableViewCell.swift

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66
//
77
// MIT License
88
//
9-
// Copyright (c) 2016 Giulio Lombardo
9+
// Copyright (c) 2017 Giulio Lombardo
1010
//
1111
// Permission is hereby granted, free of charge, to any person obtaining a copy
12-
// of this software and associated documentation files (the "Software"), to deal
13-
// in the Software without restriction, including without limitation the rights
14-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15-
// copies of the Software, and to permit persons to whom the Software is
12+
// of this software and associated documentation files (the "Software"), to
13+
// deal in the Software without restriction, including without limitation the
14+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15+
// sell copies of the Software, and to permit persons to whom the Software is
1616
// furnished to do so, subject to the following conditions:
1717
//
18-
// The above copyright notice and this permission notice shall be included in all
19-
// copies or substantial portions of the Software.
18+
// The above copyright notice and this permission notice shall be included in
19+
// all copies or substantial portions of the Software.
2020
//
2121
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2222
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2323
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2424
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27-
// SOFTWARE.
25+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27+
// IN THE SOFTWARE.
2828
//
2929

3030
import UIKit
@@ -41,7 +41,7 @@ class GLIndexedCollectionViewFlowLayout: UICollectionViewFlowLayout {
4141
return CGPoint(x: proposedContentOffset.x, y: 0)
4242
}
4343

44-
// To make paginated scrolling work fine this CGFloat below must be
44+
// To make paginated scrolling work fine this CGFloat below MUST be
4545
// equal to the value set in the insetForSectionAt method of
4646
// UICollectionView's UICollectionViewDelegate Flow Layout.
4747
let collectionViewInsets: CGFloat = 10.0
@@ -53,7 +53,7 @@ class GLIndexedCollectionViewFlowLayout: UICollectionViewFlowLayout {
5353
// Note: This will only cover horizonal scrolling and pagination, if you
5454
// need vertical pagination replace the .x coordinate with .y and update
5555
// collectionViewInsets value with the approriate one.
56-
let proposedXCoordWithInsets = proposedContentOffset.x + collectionViewInsets
56+
let proposedXCoordWithInsets: CGFloat = proposedContentOffset.x + collectionViewInsets
5757

5858
// We now create a variable and we assign a very high CGFloat to it (a
5959
// big number here is needed to cover very large
@@ -67,7 +67,7 @@ class GLIndexedCollectionViewFlowLayout: UICollectionViewFlowLayout {
6767
// cell which needs the least offsetCorrection value: it will mean that
6868
// it's the first cell on the left of the screen which will give
6969
// pagination.
70-
for layoutAttributes in super.layoutAttributesForElements(in: CGRect(x: proposedContentOffset.x, y: 0, width: collectionView!.bounds.width, height: collectionView!.bounds.height))! {
70+
for layoutAttributes: UICollectionViewLayoutAttributes in super.layoutAttributesForElements(in: CGRect(x: proposedContentOffset.x, y: 0, width: collectionView!.bounds.width, height: collectionView!.bounds.height))! {
7171
// Since layoutAttributesForElements may contain all sort of layout
7272
// attributes we need to check if it belongs to a
7373
// UICollectionViewCell, otherwise logic won't work.
@@ -110,7 +110,8 @@ class GLCollectionTableViewCell: UITableViewCell {
110110
`delegate` methods.
111111

112112
GLIndexedCollectionView requires a `strong` ARC reference, do not assign a
113-
`weak` reference otherwise it could result in a crash.
113+
`weak` reference to it otherwise it could be released unexpectedly,
114+
causing a crash.
114115

115116
*/
116117
var collectionView: GLIndexedCollectionView!
@@ -186,7 +187,7 @@ class GLCollectionTableViewCell: UITableViewCell {
186187
Re-assigns `dataSource` and `delegate` classes back to the
187188
GLIndexedCollectionView inside GLCollectionTableViewCell.
188189

189-
It's highly recommended to call this func in your [tableView(_:willDisplay:forRowAt:)](apple-reference-documentation://hs3G9NleF7)
190+
It's highly recommended to call this `func` in your [tableView(_:willDisplay:forRowAt:)](apple-reference-documentation://hs3G9NleF7)
190191
method of GLTableCollectionViewController so the UITableView will re-assign
191192
it automatically following the regular UITableViewCells reuse logic.
192193

@@ -207,7 +208,7 @@ class GLCollectionTableViewCell: UITableViewCell {
207208
will come from.
208209

209210
*/
210-
func setCollectionViewDataSourceDelegate(dataSource: UICollectionViewDataSource, delegate: UICollectionViewDelegate, indexPath: IndexPath) {
211+
func setCollectionView(dataSource: UICollectionViewDataSource, delegate: UICollectionViewDelegate, indexPath: IndexPath) {
211212
collectionView.indexPath = indexPath
212213

213214
if collectionView.dataSource == nil {

Classes/GLIndexedCollectionViewCell.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66
//
77
// MIT License
88
//
9-
// Copyright (c) 2016 Giulio Lombardo
9+
// Copyright (c) 2017 Giulio Lombardo
1010
//
1111
// Permission is hereby granted, free of charge, to any person obtaining a copy
12-
// of this software and associated documentation files (the "Software"), to deal
13-
// in the Software without restriction, including without limitation the rights
14-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15-
// copies of the Software, and to permit persons to whom the Software is
12+
// of this software and associated documentation files (the "Software"), to
13+
// deal in the Software without restriction, including without limitation the
14+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15+
// sell copies of the Software, and to permit persons to whom the Software is
1616
// furnished to do so, subject to the following conditions:
1717
//
18-
// The above copyright notice and this permission notice shall be included in all
19-
// copies or substantial portions of the Software.
18+
// The above copyright notice and this permission notice shall be included in
19+
// all copies or substantial portions of the Software.
2020
//
2121
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2222
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2323
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2424
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27-
// SOFTWARE.
25+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27+
// IN THE SOFTWARE.
2828
//
2929

3030
import UIKit

Classes/GLIndexedCollectionViewCell.xib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1212" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>

Classes/GLTableCollectionViewController.swift

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66
//
77
// MIT License
88
//
9-
// Copyright (c) 2016 Giulio Lombardo
9+
// Copyright (c) 2017 Giulio Lombardo
1010
//
1111
// Permission is hereby granted, free of charge, to any person obtaining a copy
12-
// of this software and associated documentation files (the "Software"), to deal
13-
// in the Software without restriction, including without limitation the rights
14-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15-
// copies of the Software, and to permit persons to whom the Software is
12+
// of this software and associated documentation files (the "Software"), to
13+
// deal in the Software without restriction, including without limitation the
14+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15+
// sell copies of the Software, and to permit persons to whom the Software is
1616
// furnished to do so, subject to the following conditions:
1717
//
18-
// The above copyright notice and this permission notice shall be included in all
19-
// copies or substantial portions of the Software.
18+
// The above copyright notice and this permission notice shall be included in
19+
// all copies or substantial portions of the Software.
2020
//
2121
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2222
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2323
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2424
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27-
// SOFTWARE.
25+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27+
// IN THE SOFTWARE.
2828
//
2929

3030
import UIKit
@@ -143,7 +143,7 @@ class GLTableCollectionViewController: UITableViewController, UICollectionViewDa
143143
return
144144
}
145145

146-
cell.setCollectionViewDataSourceDelegate(dataSource: self, delegate: self, indexPath: indexPath)
146+
cell.setCollectionView(dataSource: self, delegate: self, indexPath: indexPath)
147147
}
148148

149149
// MARK: <UICollectionView Data Source>
@@ -167,12 +167,21 @@ class GLTableCollectionViewController: UITableViewController, UICollectionViewDa
167167

168168
// MARK: <UICollectionViewDelegate Flow Layout>
169169

170+
let collectionTopInset: CGFloat = 0
171+
let collectionBottomInset: CGFloat = 0
172+
let collectionLeftInset: CGFloat = 10
173+
let collectionRightInset: CGFloat = 10
174+
170175
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
171-
return UIEdgeInsetsMake(0, 10, 0, 10)
176+
return UIEdgeInsetsMake(collectionTopInset, collectionLeftInset, collectionBottomInset, collectionRightInset)
172177
}
173178

174179
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
175-
return CGSize(width: 65, height: 65)
180+
let tableViewCellHeight: CGFloat = tableView.rowHeight
181+
let collectionItemWidth: CGFloat = tableViewCellHeight - (collectionLeftInset + collectionRightInset)
182+
let collectionViewHeight: CGFloat = collectionItemWidth
183+
184+
return CGSize(width: collectionItemWidth, height: collectionViewHeight)
176185
}
177186

178187
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {

GLTableCollectionView.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,12 @@
360360
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
361361
CLANG_ENABLE_OBJC_WEAK = YES;
362362
CLANG_WARN_ASSIGN_ENUM = YES;
363+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
363364
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
364365
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
366+
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
365367
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
368+
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
366369
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
367370
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
368371
CODE_SIGN_IDENTITY = "";
@@ -397,9 +400,12 @@
397400
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
398401
CLANG_ENABLE_OBJC_WEAK = YES;
399402
CLANG_WARN_ASSIGN_ENUM = YES;
403+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
400404
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
401405
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
406+
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
402407
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
408+
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
403409
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
404410
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
405411
CODE_SIGN_IDENTITY = "";

GLTableCollectionView/AppDelegate.swift

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
//
2-
// AppDelegate.swift
3-
// GLTableCollectionView
2+
// AppDelegate.swift
3+
// GLTableCollectionView
44
//
5-
// Created by Giulio Lombardo on 24/11/16.
5+
// Created by Giulio Lombardo on 24/11/16.
66
//
7-
// MIT License
7+
// MIT License
88
//
9-
// Copyright (c) 2016 Giulio Lombardo
9+
// Copyright (c) 2017 Giulio Lombardo
1010
//
11-
// Permission is hereby granted, free of charge, to any person obtaining a copy
12-
// of this software and associated documentation files (the "Software"), to deal
13-
// in the Software without restriction, including without limitation the rights
14-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15-
// copies of the Software, and to permit persons to whom the Software is
16-
// furnished to do so, subject to the following conditions:
11+
// Permission is hereby granted, free of charge, to any person obtaining a copy
12+
// of this software and associated documentation files (the "Software"), to
13+
// deal in the Software without restriction, including without limitation the
14+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15+
// sell copies of the Software, and to permit persons to whom the Software is
16+
// furnished to do so, subject to the following conditions:
1717
//
18-
// The above copyright notice and this permission notice shall be included in all
19-
// copies or substantial portions of the Software.
18+
// The above copyright notice and this permission notice shall be included in
19+
// all copies or substantial portions of the Software.
2020
//
21-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27-
// SOFTWARE.
21+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27+
// IN THE SOFTWARE.
2828
//
2929

3030
import UIKit

GLTableCollectionView/Base.lproj/LaunchScreen.storyboard

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1212" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Ik1-Jh-kcr">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Ik1-Jh-kcr">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>

GLTableCollectionView/Base.lproj/Main.storyboard

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1212" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="ClH-cz-IEW">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="ClH-cz-IEW">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>

0 commit comments

Comments
 (0)