1
我想單擊按鈕時更改按鈕(UIButton
在UICollectionViewCell
內)文本。我如何獲得單元格和按鈕?我有一個自定義單元格。UICollectionViewCell按鈕單擊並更改單元格上的文本
[cell.shareButton addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
-(void)shareAction:(UIButton*)button {
NSIndexPath *indexPath = [self.collectionView indexPathForItemAtPoint: [self.collectionView convertPoint:button.center fromView:button.superview]];
NSLog(@"row %d",indexPath.row);
NSLog(@"section %d",indexPath.section);
}
+1 button.superView獲取單元格的contentView,它的superView是UICollectionViewCell。 – Anupdas 2013-04-21 08:46:28