2 Commits

Author SHA1 Message Date
hryk224 d5afefb36d Updated 1.2.1 2017-01-05 11:14:02 +09:00
hryk224 118f9c3a45 Small changed 2017-01-05 11:12:06 +09:00
4 changed files with 14 additions and 13 deletions
+10 -3
View File
@@ -28,14 +28,21 @@ final class Pattern1ViewController: UIViewController {
pageControl.numberOfPages = itemsCount
}
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
NotificationCenter.default.addObserver(self, selector: #selector(Pattern1ViewController.rotate(_:)), name: .UIDeviceOrientationDidChange, object: nil)
}
deinit {
NotificationCenter.default.removeObserver(self, name: .UIDeviceOrientationDidChange, object: nil)
}
static func createFromStoryboard() -> Pattern1ViewController {
let storyboard = UIStoryboard(name: "Pattern1", bundle: nil)
return storyboard.instantiateInitialViewController() as! Pattern1ViewController
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
layout.itemSize = size
func rotate(_ notification: Notification) {
layout.itemSize = UIScreen.main.bounds.size
layout.invalidateLayout()
collectionView.rotate(notification)
collectionView.layoutIfNeeded()
collectionView.setNeedsLayout()
}
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "InfiniteCollectionView"
s.version = "1.2.0"
s.version = "1.2.1"
s.summary = "Infinite Scrolling Using UICollectionView."
s.homepage = "https://github.com/hryk224/InfiniteCollectionView"
s.screenshots = "https://github.com/hryk224/InfiniteCollectionView/wiki/images/sample1.gif"
@@ -33,7 +33,6 @@ open class InfiniteCollectionView: UICollectionView {
open weak var infiniteDataSource: InfiniteCollectionViewDataSource?
open weak var infiniteDelegate: InfiniteCollectionViewDelegate?
fileprivate var indexOffset: Int = 0
fileprivate var contentWidth: CGFloat = UIScreen.main.bounds.width
fileprivate var pageIndex = 0
@available(*, deprecated, message: "It becomes unnecessary because it uses UICollectionViewFlowLayout.")
open var cellWidth: CGFloat?
@@ -48,13 +47,8 @@ open class InfiniteCollectionView: UICollectionView {
deinit {
NotificationCenter.default.removeObserver(self, name: .UIDeviceOrientationDidChange, object: nil)
}
open override func reloadData() {
super.reloadData()
contentWidth = totalContentWidth
}
open func rotate(_ notification: Notification) {
contentWidth = totalContentWidth
contentOffset = CGPoint(x: CGFloat(pageIndex + indexOffset) * itemWidth, y: contentOffset.y)
setContentOffset(CGPoint(x: CGFloat(pageIndex + indexOffset) * itemWidth, y: contentOffset.y), animated: false)
}
}
@@ -78,7 +72,7 @@ private extension InfiniteCollectionView {
let currentOffset = contentOffset
let centerX = (scrollView.contentSize.width - bounds.width) / 2
let distFromCenter = centerX - currentOffset.x
if fabs(distFromCenter) > (contentWidth / 4) {
if fabs(distFromCenter) > (totalContentWidth / 4) {
let cellcount = distFromCenter / itemWidth
let shiftCells = Int((cellcount > 0) ? floor(cellcount) : ceil(cellcount))
let offsetCorrection = (abs(cellcount).truncatingRemainder(dividingBy: 1)) * itemWidth
+1 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.2.0</string>
<string>1.2.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>