I have a UICollectionView that is made up of a custom UICollectionViewCell subclass. The cell's are displaying correctly and are responding correctly to user's touches by firing this method:

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath

However, I am of the understanding that when a user touches the cell, it should highlight (in blue) and then the highlight should go away when the user lifts their finger. This is not happening. Any thoughts on why?

Here is some relevant code:

In the UICollectionView's datasource:

@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;
}

In the UICollectionViewCell's implementation:

@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];    
    }
    return self;
}

推荐答案

The class only tells you about the highlight state, but doesn't change the visual appearance. You'll have to do it programmatically by e.g. changing the background of the cell.

Details are described in the CollectionView Programming Guide.

Objective-c相关问答推荐

使用 NSMutableString 附加到文件的末尾

iPhone 可达性判断

通过指针算术访问数组值与 C 中的下标

如何创建圆形按钮?

UITabBar 中的自定义 colored颜色

保存 UIImage,以错误的方向加载它

表达式不可分配 - 将浮点数分配为 Xcode 中其他两个浮点数的总和时出现问题?

UITextView 禁用文本 Select

CF 对象与 NS 对象

无法访问 dispatch_async 中的全局变量:变量不可赋值(缺少 _block 类型说明符)

发出许多网络请求的 iOS 应用程序的最佳架构?

在 Objective C 中使用 extern

使用单独的委托/数据源时的 UITableView 问题

将 UIColor 保存到 NSUserDefaults 并从中加载

如何修复UIPopoverController 已弃用警告?

在 iOS 7 上运行应用程序时显示黑条(4 英寸视网膜显示屏)

从视图中删除所有子图层

AVAudioPlayer 不播放任何声音

Objective C 消息分发机制

CALayer:仅在一侧添加边框