Skip to content

Commit

Permalink
fixing build error for Swift 1.2 close #4
Browse files Browse the repository at this point in the history
  • Loading branch information
zhxnlai committed Apr 12, 2015
1 parent e35ceec commit d4e3ed2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions ZLBalancedFlowLayout/ZLBalancedFlowLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public class ZLBalancedFlowLayout: UICollectionViewFlowLayout {
// MARK: - Delegate Helpers
private func referenceSizeForHeader(isForHeader: Bool, inSection section: Int) -> CGSize {
if let collectionView = self.collectionView {
if let delegate = collectionView.delegate? as? UICollectionViewDelegateFlowLayout {
if let delegate = collectionView.delegate as? UICollectionViewDelegateFlowLayout {
var size:CGSize? = nil
if isForHeader {
size = delegate.collectionView?(collectionView, layout: self, referenceSizeForHeaderInSection: section)
Expand All @@ -220,7 +220,7 @@ public class ZLBalancedFlowLayout: UICollectionViewFlowLayout {

private func minimumLineSpacingForSection(section: Int) -> CGFloat {
if let collectionView = self.collectionView {
if let delegate = collectionView.delegate? as? UICollectionViewDelegateFlowLayout {
if let delegate = collectionView.delegate as? UICollectionViewDelegateFlowLayout {
if let minimumLineSpacing = delegate.collectionView?(collectionView, layout: self, minimumLineSpacingForSectionAtIndex: section) {
return minimumLineSpacing
}
Expand All @@ -231,7 +231,7 @@ public class ZLBalancedFlowLayout: UICollectionViewFlowLayout {

private func minimumInteritemSpacingForSection(section: Int) -> CGFloat {
if let collectionView = self.collectionView {
if let delegate = collectionView.delegate? as? UICollectionViewDelegateFlowLayout {
if let delegate = collectionView.delegate as? UICollectionViewDelegateFlowLayout {
if let minimumInteritemSpacing = delegate.collectionView?(collectionView, layout: self, minimumInteritemSpacingForSectionAtIndex: section) {
return minimumInteritemSpacing
}
Expand All @@ -242,7 +242,7 @@ public class ZLBalancedFlowLayout: UICollectionViewFlowLayout {

private func sizeForItemAtIndexPath(indexPath: NSIndexPath) -> CGSize {
if let collectionView = self.collectionView {
if let delegate = collectionView.delegate? as? UICollectionViewDelegateFlowLayout {
if let delegate = collectionView.delegate as? UICollectionViewDelegateFlowLayout {
if let size = delegate.collectionView?(collectionView, layout: self, sizeForItemAtIndexPath:indexPath) {
return size
}
Expand All @@ -253,7 +253,7 @@ public class ZLBalancedFlowLayout: UICollectionViewFlowLayout {

private func insetForSection(section: Int) -> UIEdgeInsets {
if let collectionView = self.collectionView {
if let delegate = collectionView.delegate? as? UICollectionViewDelegateFlowLayout {
if let delegate = collectionView.delegate as? UICollectionViewDelegateFlowLayout {
if let inset = delegate.collectionView?(collectionView, layout: self, insetForSectionAtIndex: section) {
return inset
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class ViewController: UICollectionViewController, UICollectionViewDelegateFlowLa
private var images = [UIImage](), needsResetLayout = false
private let cellIdentifier = "cell", headerIdentifier = "header", footerIdentifier = "footer"

override init(collectionViewLayout layout: UICollectionViewLayout!) {
override init(collectionViewLayout layout: UICollectionViewLayout) {
super.init(collectionViewLayout: layout)

var paths = NSBundle.mainBundle().pathsForResourcesOfType("jpg", inDirectory: "") as Array<String>
var paths = NSBundle.mainBundle().pathsForResourcesOfType("jpg", inDirectory: "") as! Array<String>
for path in paths {
if let image = UIImage(contentsOfFile: path) {
images.append(image)
Expand Down Expand Up @@ -111,7 +111,7 @@ class ViewController: UICollectionViewController, UICollectionViewDelegateFlowLa
}

override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var cell = collectionView.dequeueReusableCellWithReuseIdentifier(cellIdentifier, forIndexPath: indexPath) as UICollectionViewCell
var cell = collectionView.dequeueReusableCellWithReuseIdentifier(cellIdentifier, forIndexPath: indexPath) as! UICollectionViewCell
var imageView = UIImageView(image: imageForIndexPath(indexPath))
imageView.contentMode = .ScaleAspectFill
cell.backgroundView = imageView
Expand All @@ -123,10 +123,10 @@ class ViewController: UICollectionViewController, UICollectionViewDelegateFlowLa
var view = LabelCollectionReusableView(frame: CGRectZero)
switch (kind) {
case UICollectionElementKindSectionHeader:
view = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionHeader, withReuseIdentifier: headerIdentifier, forIndexPath: indexPath) as LabelCollectionReusableView
view = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionHeader, withReuseIdentifier: headerIdentifier, forIndexPath: indexPath) as! LabelCollectionReusableView
view.textLabel.text = "Header"
case UICollectionElementKindSectionFooter:
view = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionFooter, withReuseIdentifier: footerIdentifier, forIndexPath: indexPath) as LabelCollectionReusableView
view = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionFooter, withReuseIdentifier: footerIdentifier, forIndexPath: indexPath) as! LabelCollectionReusableView
view.textLabel.text = "Footer"
default:
view.textLabel.text = "N/A"
Expand Down

0 comments on commit d4e3ed2

Please sign in to comment.