相关疑难解决方法(0)

为什么UICollectionView的UICollectionViewCell没有突出显示用户触摸?

我有一个UICollectionView,它由一个自定义的UICollectionViewCell子类组成.单元格正确显示,并通过触发此方法正确响应用户的触摸:

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)

但是,我理解当用户触摸单元格时,它应该突出显示(蓝色),然后当用户抬起手指时高光应该消失.这不会发生.有什么想法吗?

这是一些相关的代码:

在UICollectionView的数据源中:

@implementation SplitCheckViewCollection

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifier = @"ReceiptCellIdentifier";
    SplitCheckCollectionCell *cell = (SplitCheckCollectionCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
    cell.cellName.text = [NSString stringWithFormat:@"%@%i",@"#",indexPath.row+1];

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

在UICollectionViewCell的实现中:

@implementation SplitCheckCollectionCell

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"SplitCheckCollectionCell" owner:self options:nil];

        if ([arrayOfViews count] < 1) {
            return nil;
        }

        if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionViewCell class]]) {
            return nil;
        }

        self = [arrayOfViews objectAtIndex:0];    
    } …
Run Code Online (Sandbox Code Playgroud)

objective-c ios uicollectionview

39
推荐指数
6
解决办法
5万
查看次数

标签 统计

ios ×1

objective-c ×1

uicollectionview ×1