Прямо сейчас у меня есть список прокручиваемых имен пользователей, используя коллекцию View of buttons. Но я хотел бы добавить перекрывающиеся кнопки удаления в каждую строку. Они должны быть прикреплены к кнопкам имен и прокручивать их.Как добавить кнопку удаления в коллекцию View Cell в Swift?
Как добавить эти кнопки в свой 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)
}
}
Что такое 'UserSelectCollection'? – maidi
'UserSelectCollection', скорее всего, его коллекция. – FunkyMonk91
Привет, я добавил метод addTarget, но показывая ошибку. «Значение типа« UILabel »не имеет никакого« addTarget »участника.« Любой альтернативный способ сделать @Justin Lewis –