如何检查indexPath是否有效,从而避免“尝试滚动到无效索引路径”;错误? [英] How can I check if an indexPath is valid, thus avoiding an "attempt to scroll to invalid index path" error?

查看:2946
本文介绍了如何检查indexPath是否有效,从而避免“尝试滚动到无效索引路径”;错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何查看indexPath是否有效?

How can I check to see whether an indexPath is valid or not?

我想滚动到索引路径,但如果我的收藏有时会出错视图的子视图未完成加载。

I want to scroll to an index path, but I sometimes get an error if my collection view's subviews aren't finished loading.

推荐答案

您可以查看

- numberOfSections
- numberOfItemsInSection: 

你的 UICollection查看数据源以查看您的indexPath是否有效。

of your UICollection​View​Data​Source to see if your indexPath is a valid one.

这篇关于如何检查indexPath是否有效,从而避免“尝试滚动到无效索引路径”;错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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