swift - 如何在 Swift 中预取从 URL 播放的视频
问题描述
我有一个收藏视图,其中包含我从单元 willDisplay播放的视频,如下所示:
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
if let cell = cell as? UserFeedCollectionViewCell {
let post = feed[indexPath.row]
cell.videoplayer.play(post: post)
}
}
加载视频需要一些时间(有时需要 1-2 秒),我想提高应用程序的性能。
在这种情况下预取是个好主意吗?我不知道该放什么
func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) {
}
解决方案
推荐阅读
- python - TypeError:join() 参数必须是 str、bytes 或 os.PathLike 对象,而不是“元组”
- dataframe - PySpark 删除所有特殊字符的所有列名中的特殊字符 - 错误无法解析给定列
- openshift - Openshift 路线偏好?
- reactjs - React - 来自组件类的输入目标值
- c++ - 从 QML 中的子文件夹集成 C++ 类
- java - 在 Groovy 中创建 Map.Entry 实例
- reactjs - NextJs Index.html 文件未在公用文件夹中生成
- javascript - 验证字符串时间范围
- python - 如何使用 ForeignKeyConstraint 和复合外键与 SQLAlchemy 级联删除?
- salesforce-commerce-cloud - 无法访问网站某一部分的 URL 或 pdict 值