소스 검색

禁用自动循环

jsonwang 4 년 전
부모
커밋
2062cd482e
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      MusicVideoPlus/MusicVideoPlus/Classes/Modules/Home/Views/Banner/MVBanner.swift

+ 4 - 1
MusicVideoPlus/MusicVideoPlus/Classes/Modules/Home/Views/Banner/MVBanner.swift

@@ -250,7 +250,10 @@ extension MVBanner: UIScrollViewDelegate {
     }
     public func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) {
         scrollView.isPagingEnabled = false
-        self.scrollToItem(at: self.currentIndex, animated: true)
+        if(self.currentIndex >= 0 && self.currentIndex <  self.dataSource?.numberOfItems() ?? 0){
+            self.scrollToItem(at: self.currentIndex, animated: true)
+        }
+
     }
     public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
         scrollView.isPagingEnabled = false