ตอนนี้ฉันมีรายการชื่อผู้ใช้แบบเลื่อนโดยใช้มุมมองคอลเลกชันของปุ่ม แต่ฉันต้องการเพิ่มปุ่มลบที่ทับซ้อนกันในแต่ละแถว พวกเขาจะต้องแนบไปกับปุ่มชื่อและเลื่อนไปด้วย
ฉันจะเพิ่มปุ่มเหล่านี้ใน CollectionView ของฉันได้อย่างไร (และฉันต้องการข้ามปุ่มลบในแถวแรกด้วยเหตุผลที่ชัดเจน)
รหัสปัจจุบัน:
//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)
}
}