Saat ini saya memiliki daftar nama pengguna yang dapat digulir menggunakan tombol Tampilan Koleksi. Tapi saya ingin menambahkan tombol hapus yang tumpang tindih ke setiap baris. Mereka harus dilampirkan ke tombol nama dan menggulirnya.
Bagaimana cara menambahkan tombol-tombol ini ke CollectionView saya? (Saya juga ingin melewatkan tombol hapus di baris pertama karena alasan yang jelas)
Kode Saat Ini:
//Add the cells to collection
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell: UsernameCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! UsernameCollectionViewCell
cell.usernameLabel.text = userNames [indexPath.row]
return cell
}
//Upon Selecting an item
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
if (indexPath.row == 0){
self.performSegueWithIdentifier("newUserSegue", sender: self)
}
else {
sendData(userNames[indexPath.row])
self.dismissViewControllerAnimated(true, completion: nil)
}
}