【发布时间】:2017-05-28 20:17:12
【问题描述】:
我有这个方法:
-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
CGPoint p = [gestureRecognizer locationInView:self.collectionView];
NSIndexPath *indexPath = [self.collectionView indexPathForItemAtPoint:p];
if (indexPath == nil){
NSLog(@"couldn't find index path");
} else {
UICollectionViewCell* cell = [self.collectionView cellForItemAtIndexPath:indexPath];
if ([cell isKindOfClass:[MWGradeCell class]]){
NSLog(@"Yes");
//here I would like to get a custom property "cell.gradeLabel.text" that is specific to MWGradeCell
} else{
NSLog(@"No");
}
}
} else{
NSLog(@"ended");
}
}
它识别 UICollectionview 的哪个 UICollectionviewcell 被长按。 我的 UICollectionView 是用不同类型的子类 UICollectionViewCells 构建的,每个子类都有不同的属性。
现在,我只想获取特定单元格类型的属性,但为了做到这一点,我需要将已识别的 UICollectionViewCell 更改为 MWGradeCell。
不知道怎么做。幸运的是,你们在身边
【问题讨论】: