UICollectionView 单元格在点击时更改背景 [英] UICollectionView cell change background while tap

查看:60
本文介绍了UICollectionView 单元格在点击时更改背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能仅在点击元素时更改 UICollectionView 的背景颜色.我试过了:

Is there a possibility to change the background color of UICollectionView only while the element is tapped. I have tried:

-(void) collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath{
    //change color when tapped
}

-(void)collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath{
    //change back on touch up 
}

但结果是,只有当我保持手指更长的时间时,我才能看到变化.UITableViewCell 方法 willSelectItemAtIndexPath: 中是否有类似的东西?

But the result is that I can see the change only when i keep my finger for a bit longer time. Is there some similar stuff like in UITableViewCell method willSelectItemAtIndexPath:?

推荐答案

但结果是,我只有保持手指更长的时间才能看到变化

But the result is that I can see the change only when i keep my finger for a bit longer time

您遇到的延迟可能与情节提要中的延迟内容接触"复选框有关.

The delay your are experiencing is probably related to the "Delay content touches" checkbox in the storyboard.

尝试取消选中它.

这篇关于UICollectionView 单元格在点击时更改背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆