marinofaggiana 6 年之前
父節點
當前提交
e2be35eb8b
共有 1 個文件被更改,包括 10 次插入3 次删除
  1. 10 3
      iOSClient/Media/NCMedia.swift

+ 10 - 3
iOSClient/Media/NCMedia.swift

@@ -522,9 +522,16 @@ class NCMedia: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
     }
     }
     
     
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-        let key = sectionDatasource.sections.object(at: section)
-        let datasource = sectionDatasource.sectionArrayRow.object(forKey: key) as! [tableMetadata]
-        return datasource.count
+        
+        var numberOfItemsInSection: Int = 0
+        
+        if section < sectionDatasource.sections.count {
+            let key = sectionDatasource.sections.object(at: section)
+            let datasource = sectionDatasource.sectionArrayRow.object(forKey: key) as! [tableMetadata]
+            numberOfItemsInSection = datasource.count
+        }
+        
+        return numberOfItemsInSection
     }
     }
     
     
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {