I have a View Controller with a UICollectionView
. Each UICollectionViewCell
has one UILabel
and one UIButton
. How can I print the text of each UILabel
in the UICollectionView
when clicking the corresponding UIButton
.
If I understood you right, you can subclass your UICollectionViewCell
, link UILabel
to corresponding property and create a method for UIButton
touch. Here is the sample code of this method:
@interface MyCustomCollectionViewCell: UICollectionViewCell
@property (weak, nonatomic) IBOutlet UILabel *cellLabel;
- (void)cellButtonClicked:(id)sender;
@end
@implementation
- (void)cellButtonClicked:(id)sender {
NSLog(@"%@",_cellLabel.text);
}
@end
Besides it, you can look through some guide, eg this one .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.