我有一个UIViewController
与UICollectionView
附加上。问题是每当我向上滚动集合视图时都会调用viewForSupplementaryElementOfKind
。有什么方法可以多次停止呼叫viewForSupplementaryElementOfKind
?UICollectionView viewForSupplementaryElementOfKind多次调用
0
A
回答
0
viewForSupplementaryElementOfKind
的调用取决于部分的数量和部分页眉/页脚的可用性。 viewForSupplementaryElementOfKind将被调用,每当具有页眉或页脚的部分显示在视图中
0
最后,我想出了一个解决方案,像一个魅力... 我设置标签值为每次我创建它并检查标记值是否设置在viewForSupplementaryElementOfKind
中时,每当我进入循环时。如果它被设置已经那么它将不会再重新设计标签
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
if ([kind isEqualToString:UICollectionElementKindSectionHeader])
{
UICollectionReusableView *reusableview = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath];
if([reusableview viewWithTag:101] == nil)
{
[[reusableview viewWithTag:101] removeFromSuperview];
pointsAmountLabel = [[UILabel alloc] init];
pointsAmountLabel.frame = CGRectMake(0, 20, [UIScreen mainScreen].bounds.size.width, 20);
pointsAmountLabel.text = @"0";
pointsAmountLabel.tag = 101;
pointsAmountLabel.font = [UIFont boldSystemFontOfSize:16];
[reusableview addSubview:pointsAmountLabel];
}
return reusableview;
}
return nil;
}
相关问题
- 1. UICollectionView防止多次轻击/调用didSelectItemAt
- 2. viewForSupplementaryElementOfKind未在自定义UICollectionViewLayout上调用
- 3. UICollectionView cellForItemAt第二次没有调用
- 4. 多次调用
- 5. UICollectionView单元格配置太多次
- 6. 多UICollectionView
- 7. LeveyPopListView多次调用
- 8. ABAddressBookRegisterExternalChangeCallback多次调用
- 9. 多次调用CryptHashData
- 10. 多次调用ReactDOM.render
- 11. observeValueForKeyPath多次调用
- 12. ON_EN_KILLFOCUS多次调用
- 13. GetView调用多次
- 14. didUpdateToLocation多次调用
- 15. 多次调用NSManagedObjectContextDidSaveNotification
- 16. onPerformSync()多次调用
- 17. onReceive多次调用
- 18. 多次调用malloc
- 19. pthread_atfork()多次调用导致fork()函数被多次调用后
- 20. RxSwift和UICollectionView标头
- 21. UICollectionView不能调用scrollViewDidScroll - Swift
- 22. scrollViewWillBeginDragging:未在UICollectionview中调用
- 23. UICollectionView的scrollToItem不调用targetContentOffset
- 24. 跨多个UICollectionViewControllers重用UICollectionView
- 25. 对TWebModule.SendDirect的多次调用
- 26. jQuery多次函数调用
- 27. 调用了多少次onDraw()?
- 28. onChildRemoved()获取多次调用
- 29. 多次调用onmouseover函数
- 30. 多次调用viewDidLoad/loadView
它是根据你的部分称为数 –
是否有任何解决方案停止调用一个以上的时间? –
哈哈哈,然后做喜欢,设置一个部分,并添加另一个东西是行 –