uicollectionview在reloaddata之后立即选择一个项目? [英] uicollectionview select an item immediately after reloaddata?

查看:134
本文介绍了uicollectionview在reloaddata之后立即选择一个项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用 - [UICollectionView reloadData] 后,显示单元格需要一些时间,因此在调用 reloadData 不起作用。有没有办法在 reloadData 之后立即选择一个项目?

After calling -[UICollectionView reloadData] it takes some time for cells to be displayed, so selecting an item immediately after calling reloadData does not work. Is there a way to select an item immediately after reloadData?

推荐答案

按照这个答案,我发现在<之后调用 layoutIfNeeded code> reloadData 似乎在我对collectionView执行其他操作之前有效地刷新重新加载:

Along the lines of this answer I found that calling layoutIfNeeded after reloadData seemed to effectively 'flush' the reload before I do other things to the collectionView:

[self.collectionView reloadData];
[self.collectionView layoutIfNeeded];
...

在页面上我找到了这个解决方案,一些评论者指出它没有'在iOS 9上为他们工作,但对我来说没问题,所以你的里程可能会有所不同。

On the page I found this solution, some commenters indicated it didn't work for them on iOS 9, but it's been fine for me so your mileage may vary.

这篇关于uicollectionview在reloaddata之后立即选择一个项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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