1
我正在swift 3中處理項目,目前我可以通過拖動一個接一個地瀏覽UICollectionView項目。我的要求是在屏幕出現時將它們(項目)顯示爲幻燈片而不拖動它們(需要禁用該項目)。我現在的代碼如下圖所示。由於我對新的快速幫助將非常感激。當視圖像幻燈片一樣顯示時,自動滾動UICollectionView元素。
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "SuggestedCell", for: indexPath) as! SuggestedMP3CollectionViewCell
//background of collectionview
let view=UIView()
view.backgroundColor=UIColor(patternImage:collectionViewImageArray [indexPath.row])
cell.backgroundView=view
cell.featuredSongLabel.text = "Featured Song"
cell.suggestedHealerNameLabel.text = "Healer"
cell.suggestedTeaserDescriptionLabel.text = "Teaser"
cell.suggestedMusicImageView.image = imageArray [indexPath.row]
// cell.suggestedMusicImageView.image = collectionViewImageArray [indexPath.row]
return cell
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 20
//return collectionViewCount!
}
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
在「下一頁」功能,您可以解釋一下什麼是「self.banner.count」 – danutha
對我來說self.banner.count給出的CollectionView細胞的數量,self.banner是對象 –
的陣列十分感謝 – danutha