我想在用戶點擊按鈕的時候將節的數量加1,但我不知道該如何將它寫入代碼。Xcode Swift Collection View:如何在點擊按鈕時在節中添加項目數量?
@IBAction func myButton(_ sender: Any) {
let numberOfItemsInSection + 1 //What's the correct way to write this line of code?
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 0 // +1 whenever the button gets tapped
}
使用一個變量並返回它'numberOfItemsInSection'功能......要添加然後只需+1並重新載入表 – Tj3n