ios - UICollectionViewCell 未在 UITabBarController 选项卡更改后立即加载
问题描述
好的,所以我有部分代码在其中更改UITabBarController's
选项卡(更改为 a UICollectionView
),然后在它之后显示一个弹出窗口,其中包含特定单元格的 sourceView 和 sourceRect UICollectionView
。
我遇到的问题是,当我事先浏览该选项卡时,一切正常。
但是,一旦我尝试不选择该选项卡,它就会由于未加载单元格而崩溃。这听起来很公平,但我该如何解决呢?
做一些 0.1 秒的调度延迟似乎是一个可疑的解决方案..
tabBarController.selectedViewController = vc
if let cell = vc.collectionView?.cellForItem(at: IndexPath(item: index, section: 0)) {
alertVC.popoverPresentationController?.sourceView = cell
alertVC.popoverPresentationController?.sourceRect = cell.bounds
}
// if statement gets ignored as cv is not yet loaded as it seems
解决方案
推荐阅读
- python - 添加两个参数会导致 NoReverseMatch
- javascript - 引用我希望从服务器接收的数据
- amazon-web-services - VPCa 中的 Tableau 服务器从 vpcB 中的 RDS 中提取数据
- javascript - Azure 语音服务 (Javascript) startContinuousRecognitionAsync() 中 RecognitionMode 参数的含义
- postgresql - autovacuum (VACUUM) 是这个 PostgreSQL UPDATE 查询偶尔需要几个小时才能完成运行的原因吗?
- python - 使用 python Web Scraper 提取 n 个图像
- webpack - AWS Lambda - Runtime.ImportModuleError:错误:找不到模块“../package.json”
- mysql - Mysql 查询不起作用,尤其是 Scan() 方法
- python - Errno 24 在 Python 中进行多处理时打开的文件过多
- python - dask 分布式异常报告进度条