Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
// swift-tools-version:5.4.0
import PackageDescription

let package = Package(
name: "InfiniteCollectionView",
targets: [],
dependencies: [
.Package(url: "https://github.com/hryk224/InfiniteCollectionView", majorVersion: 1),
]
platforms: [
.iOS(.v10),
],
products: [
.library(
name: "InfiniteCollectionView",
targets: ["InfiniteCollectionView"]
)
],
targets: [
.target(name: "InfiniteCollectionView", path: "Sources"),
]
)
8 changes: 4 additions & 4 deletions Sources/InfiniteCollectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ open class InfiniteCollectionView: UICollectionView {
configure()
}
deinit {
NotificationCenter.default.removeObserver(self, name: .UIDeviceOrientationDidChange, object: nil)
NotificationCenter.default.removeObserver(self, name: UIDevice.orientationDidChangeNotification, object: nil)
}
open func rotate(_ notification: Notification) {
@objc open func rotate(_ notification: Notification) {
setContentOffset(CGPoint(x: CGFloat(pageIndex + indexOffset) * itemWidth, y: contentOffset.y), animated: false)
}
open override func selectItem(at indexPath: IndexPath?, animated: Bool, scrollPosition: UICollectionViewScrollPosition) {
open override func selectItem(at indexPath: IndexPath?, animated: Bool, scrollPosition: UICollectionView.ScrollPosition) {
guard let indexPath = indexPath else { return }
// Correct the input IndexPath
let correctedIndexPath = IndexPath(row: correctedIndex(indexPath.item + indexOffset), section: 0)
Expand Down Expand Up @@ -84,7 +84,7 @@ private extension InfiniteCollectionView {
delegate = self
dataSource = self
register(UICollectionViewCell.self, forCellWithReuseIdentifier: defaultIdentifier)
NotificationCenter.default.addObserver(self, selector: #selector(InfiniteCollectionView.rotate(_:)), name: .UIDeviceOrientationDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(InfiniteCollectionView.rotate(_:)), name: UIDevice.orientationDidChangeNotification, object: nil)
}
func centerIfNeeded(_ scrollView: UIScrollView) {
let currentOffset = contentOffset
Expand Down