0
我有这样的方法:更改泛型类类型为子
-(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。
不知道如何。幸运的是,你人身边
谢谢,我做那。但该应用程序坠毁在不同的类。然后我尝试了上面的代码。我应该结合这两种方法。是的,(MWGradeCell *)是必需的,否则cellforitematindexpath将不起作用。 – Sjakelien