[英]How to get the label in the collection cell when click a button in the same collection cell
我有一个带有UICollectionView
的视图控制器。 每个UICollectionViewCell
都有一个UILabel
和一个UIButton
。 单击相应的UIButton
时,如何在UICollectionView
打印每个UILabel
的文本。
如果我理解正确,则可以UICollectionViewCell
子类,将UILabel
链接到相应的属性,并创建用于UIButton
touch的方法。 这是此方法的示例代码:
@interface MyCustomCollectionViewCell: UICollectionViewCell
@property (weak, nonatomic) IBOutlet UILabel *cellLabel;
- (void)cellButtonClicked:(id)sender;
@end
@implementation
- (void)cellButtonClicked:(id)sender {
NSLog(@"%@",_cellLabel.text);
}
@end
除此之外,您还可以浏览一些指南,例如本指南。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.