diff --git a/Package.swift b/Package.swift index 1cdafc7..1f15e94 100644 --- a/Package.swift +++ b/Package.swift @@ -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"), + ] ) diff --git a/Sources/InfiniteCollectionView.swift b/Sources/InfiniteCollectionView.swift index 5111dde..8ff2bcc 100644 --- a/Sources/InfiniteCollectionView.swift +++ b/Sources/InfiniteCollectionView.swift @@ -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) @@ -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