Xcode collectionView中的UIButton不';不保留突出显示

Xcode collectionView中的UIButton不';不保留突出显示,xcode,Xcode,我有一个collectionView,每个单元格都有一个按钮。我有一个自定义的单元格类。当我按下一个按钮时,它会高亮显示,然后迅速恢复正常(可能在0.5-1秒内) -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { GridControlViewOutputCell * outputCell;

我有一个collectionView,每个单元格都有一个按钮。我有一个自定义的单元格类。当我按下一个按钮时,它会高亮显示,然后迅速恢复正常(可能在0.5-1秒内)

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    GridControlViewOutputCell * outputCell;
    outputCell = (GridControlViewOutputCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"gridControlViewOutputCell" forIndexPath:indexPath];
    if(outputCell == nil)
    {
        outputCell = [[GridControlViewOutputCell alloc] init];
    }
    outputCell.outputDelegate = self;
    outputCell.ioIndex = indexPath.row;
    [outputCell.outputButton setUserInteractionEnabled:true];
    [outputCell.outputButton setAdjustsImageWhenHighlighted:true];
    [outputCell.outputButton setAdjustsImageWhenDisabled:true];
    [outputCell.outputButton setBackgroundColor:[UIColor clearColor]];
    [outputCell.outputButton setBackgroundImage:[[UIImage imageNamed:@"btn_normal.png"] stretchableImageWithLeftCapWidth:12 topCapHeight:12] forState:UIControlStateNormal];
    [outputCell.outputButton setBackgroundImage:[[UIImage imageNamed:@"btn_pressed.png"] stretchableImageWithLeftCapWidth:12 topCapHeight:12] forState:UIControlStateHighlighted];
    if([buttons count] > indexPath.row)
    {
        [buttons replaceObjectAtIndex:indexPath.row withObject:outputCell.outputButton];
    }
    else{
        [buttons insertObject:outputCell.outputButton atIndex:indexPath.row];
    }
    return outputCell;
}

#import "GridControlViewOutputCell.h"

@implementation GridControlViewOutputCell
@synthesize outputDelegate;
@synthesize ioIndex;
@synthesize outputButton;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    return self;
}

-(IBAction)buttonPressed:(id)sender
{
    [outputDelegate outputChanged:ioIndex on:true];
}

-(IBAction)buttonReleased:(id)sender
{
    [outputDelegate outputChanged:ioIndex on:false];
}

@end
按下按钮与触地相连

按钮释放绑定到触摸取消、拖动退出、内部触摸(尽管我不确定是否需要触摸取消)

事件按预期触发,只是按住按钮时突出显示没有“粘住”

编辑:我只是想澄清一下,我并没有试图在释放按钮后使其高亮显示。这里有几个与此相关的问题。我只是试图在按下按钮时使其高亮显示