我怎么知道 UICollectionView 已经完全加载了? [英] How do I know that the UICollectionView has been loaded completely?

查看:38
本文介绍了我怎么知道 UICollectionView 已经完全加载了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当 UICollectionView 完全加载时,我都必须进行一些操作,即那时应该调用所有 UICollectionView 的数据源/布局方法.我怎么知道??是否有任何委托方法可以知道 UICollectionView 加载状态?

I have to do some operation whenever UICollectionView has been loaded completely, i.e. at that time all the UICollectionView's datasource / layout methods should be called. How do I know that?? Is there any delegate method to know UICollectionView loaded status?

推荐答案

// In viewDidLoad
[self.collectionView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionOld context:NULL];

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary  *)change context:(void *)context
{
    // You will get here when the reloadData finished 
}

- (void)dealloc
{
    [self.collectionView removeObserver:self forKeyPath:@"contentSize" context:NULL];
}

这篇关于我怎么知道 UICollectionView 已经完全加载了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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