簡體   English   中英

單元格內部的UIButton

[英]UIButton inside cell programmatically

當我將UIButton放在UICollectionView的單元格類中時,目標是誰? 我不能將target設置為“ self”,但是它必須是父collectionView,在其中我沒有指向單元格類的指針。

//inside a cell class (`uicollectionviewcell`)


  [self.deleteCell addTarget:self action:@selector(clearCell:)forControlEvents:UIControlEventTouchUpInside];

代替self應該是什么?

在此方法上將目標自身添加到集合中:

   - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

我用cell.button進入那個按鈕的cell.button ,然后將目標添加到self(這是集合)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM