我如何知道UICollectionView已经完全加载? [英] How do I know that the UICollectionView has been loaded completely?
本文介绍了我如何知道UICollectionView已经完全加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
//在viewDidLoad
[self.collectionView addObserver:self forKeyPath:@contentSize选项:NSKeyValueObservingOptionOld上下文:NULL];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)更改上下文:(void *)context
{
//当reloadData完成
}
- (void)dealloc
{
[self.collectionView removeObserver:self forKeyPath:@contentSizecontext:空值];
}
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屋!
查看全文