UICollectionView selectItemAtIndexPath不调用didSelectItemAtIndexPath [英] UICollectionView selectItemAtIndexPath doesn't call didSelectItemAtIndexPath

查看:365
本文介绍了UICollectionView selectItemAtIndexPath不调用didSelectItemAtIndexPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个收藏夹视图.我想以编程方式选择一个单元格.这是我使用的代码

I have a collection view. I would like to programmatically select a cell. This is the code I use

[_collectionView selectItemAtIndexPath:[NSIndexPath indexPathForItem:currentSelectedVideo inSection:0] animated:YES scrollPosition:UICollectionViewScrollPositionNone];

出于某些原因,这些功能:

For some reason the functions:

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

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

未调用,因此我用于显示所选单元格的视觉效果未显示在屏幕上.

Are not called and therefore the visual effect I am using for showing the selected cell is not shown on the screen.

这是适当的行为吗?

推荐答案

是的,这是正确的行为.有关的文件[selectItemAtIndexPath:animated:scrollPosition:]说:

Yes, this is proper behaviour. Documentation for [selectItemAtIndexPath:animated:scrollPosition:] says:

此方法不会导致任何与选择相关的委托方法被调用.

This method does not cause any selection-related delegate methods to be called.

这篇关于UICollectionView selectItemAtIndexPath不调用didSelectItemAtIndexPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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