collection view support
This commit is contained in:
parent
0882f8d274
commit
a5f9081b97
|
|
@ -52,6 +52,8 @@
|
|||
78D4B5461DA64D49005B0764 /* UIViewController+DefaultStoryboardIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78D4B5451DA64D49005B0764 /* UIViewController+DefaultStoryboardIdentifier.swift */; };
|
||||
78D4B54A1DA64EAB005B0764 /* Any+TypeName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78D4B5491DA64EAB005B0764 /* Any+TypeName.swift */; };
|
||||
95B39A861D9D51250057BD54 /* String+Localization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95B39A851D9D51250057BD54 /* String+Localization.swift */; };
|
||||
E126CBB31DB68DDA00E1B2F8 /* UICollectionView+CellRegistration.swift in Sources */ = {isa = PBXBuildFile; fileRef = E126CBB21DB68DDA00E1B2F8 /* UICollectionView+CellRegistration.swift */; };
|
||||
E126CBB51DB6904B00E1B2F8 /* UICollectionView+DequeueCustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E126CBB41DB6904B00E1B2F8 /* UICollectionView+DequeueCustomCell.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
|
|
@ -113,6 +115,8 @@
|
|||
78D4B5451DA64D49005B0764 /* UIViewController+DefaultStoryboardIdentifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+DefaultStoryboardIdentifier.swift"; sourceTree = "<group>"; };
|
||||
78D4B5491DA64EAB005B0764 /* Any+TypeName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Any+TypeName.swift"; sourceTree = "<group>"; };
|
||||
95B39A851D9D51250057BD54 /* String+Localization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+Localization.swift"; sourceTree = "<group>"; };
|
||||
E126CBB21DB68DDA00E1B2F8 /* UICollectionView+CellRegistration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UICollectionView+CellRegistration.swift"; path = "UICollectionView/UICollectionView+CellRegistration.swift"; sourceTree = "<group>"; };
|
||||
E126CBB41DB6904B00E1B2F8 /* UICollectionView+DequeueCustomCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UICollectionView+DequeueCustomCell.swift"; path = "UICollectionView/UICollectionView+DequeueCustomCell.swift"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
|
@ -309,6 +313,7 @@
|
|||
787783611CA03C84001CDC9B /* IndexPath */,
|
||||
78E59B2C1C786CD500C6BFE9 /* UIView */,
|
||||
78E59B2B1C786CBF00C6BFE9 /* UITableView */,
|
||||
E126CBB11DB68D9A00E1B2F8 /* UICollectionView */,
|
||||
C37210711ACDF1042F70C2EB /* UIImage */,
|
||||
780D23411DA412330084620D /* CGImage */,
|
||||
780D23441DA416E80084620D /* CGContext */,
|
||||
|
|
@ -386,6 +391,15 @@
|
|||
path = UIStoryboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E126CBB11DB68D9A00E1B2F8 /* UICollectionView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E126CBB21DB68DDA00E1B2F8 /* UICollectionView+CellRegistration.swift */,
|
||||
E126CBB41DB6904B00E1B2F8 /* UICollectionView+DequeueCustomCell.swift */,
|
||||
);
|
||||
name = UICollectionView;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
|
|
@ -552,6 +566,7 @@
|
|||
files = (
|
||||
7837F60F1CBCF5C0000D74C1 /* EstimatedViewHeightProtocol.swift in Sources */,
|
||||
78CFEE541C5C45E500F50370 /* UIView+LoadFromNib.swift in Sources */,
|
||||
E126CBB51DB6904B00E1B2F8 /* UICollectionView+DequeueCustomCell.swift in Sources */,
|
||||
78D4B5461DA64D49005B0764 /* UIViewController+DefaultStoryboardIdentifier.swift in Sources */,
|
||||
78CFEE521C5C45E500F50370 /* UITableView+CellRegistration.swift in Sources */,
|
||||
78B0FC7F1C6B2C4D00358B64 /* Log.swift in Sources */,
|
||||
|
|
@ -578,6 +593,7 @@
|
|||
78CFEE5A1C5C45E500F50370 /* ViewHeightProtocol.swift in Sources */,
|
||||
787682FA1CAD40C300532AB3 /* StaticEstimatedViewHeightProtocol.swift in Sources */,
|
||||
78A74EA91C6B373700FE9724 /* UIView+DefaultNibName.swift in Sources */,
|
||||
E126CBB31DB68DDA00E1B2F8 /* UICollectionView+CellRegistration.swift in Sources */,
|
||||
78CFEE581C5C45E500F50370 /* StaticViewHeightProtocol.swift in Sources */,
|
||||
787783631CA03CA0001CDC9B /* IndexPath+ImmutableIndexPath.swift in Sources */,
|
||||
78B036471DA5624D0021D5CC /* CGImage+Creation.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// UICollectionView+CellRegistration.swift
|
||||
// LeadKit
|
||||
//
|
||||
// Created by Fedor on 18.10.16.
|
||||
// Copyright © 2016 Touch Instinct. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
public extension UICollectionView {
|
||||
/**
|
||||
method which register UICollectionViewCell subclass for reusing in UICollectionView with reuse identifier
|
||||
provided by ReuseIdentifierProtocol protocol implementation and nib name
|
||||
provided by StaticNibNameProtocol protocol implementation
|
||||
|
||||
- parameter cellClass: UICollectionViewCell subclass which implements ReuseIdentifierProtocol and StaticNibNameProtocol
|
||||
|
||||
- see: ReuseIdentifierProtocol, StaticNibNameProtocol
|
||||
*/
|
||||
|
||||
public func registerNib<T>(forCellClass cellClass: T.Type)
|
||||
where T: ReuseIdentifierProtocol, T: UICollectionViewCell, T: StaticNibNameProtocol {
|
||||
|
||||
self.register(UINib(nibName: T.nibName), forCellReuseIdentifier: T.reuseIdentifier)
|
||||
}
|
||||
|
||||
/**
|
||||
method which register UICollectionViewCell subclass for reusing in UICollectionView with reuse identifier
|
||||
provided by ReuseIdentifierProtocol protocol implementation and nib name
|
||||
provided by NibNameProtocol protocol implementation
|
||||
|
||||
- parameter cellClass: UICollectionViewCell subclass which implements ReuseIdentifierProtocol and NibNameProtocol
|
||||
- parameter interfaceIdiom: UIUserInterfaceIdiom value for NibNameProtocol
|
||||
|
||||
- see: ReuseIdentifierProtocol, NibNameProtocol
|
||||
*/
|
||||
|
||||
public func registerNib<T>(forCellClass cellClass: T.Type,
|
||||
forUserInterfaceIdiom interfaceIdiom: UIUserInterfaceIdiom)
|
||||
where T: ReuseIdentifierProtocol, T: UICollectionViewCell, T: NibNameProtocol {
|
||||
|
||||
let nib = UINib(nibName: T.nibName(forConfiguration: interfaceIdiom))
|
||||
self.register(nib, forCellReuseIdentifier: T.reuseIdentifier)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// UICollectionView+DequeueCustomCell.swift
|
||||
// LeadKit
|
||||
//
|
||||
// Created by Fedor on 18.10.16.
|
||||
// Copyright © 2016 Touch Instinct. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
public extension UICollectionView {
|
||||
/**
|
||||
method for dequeueing reusable table view cell with specific class using reuse identifier
|
||||
provided by ReuseIdentifierProtocol implementation
|
||||
|
||||
- parameter indexPath: NSIndexPath object
|
||||
|
||||
- returns: UICollectionViewCell subclass instance
|
||||
|
||||
- see: ReuseIdentifierProtocol
|
||||
*/
|
||||
|
||||
public func dequeueReusableCell<T>(forIndexPath indexPath: IndexPath) -> T
|
||||
where T: UICollectionViewCell, T: ReuseIdentifierProtocol {
|
||||
|
||||
return self.dequeueReusableCell(withIdentifier: T.reuseIdentifier, for: indexPath) as! T
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue