我有一個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 viewForSupplementaryElementOfKind未使用Firebase UI數據調用來源
- 2. UICollectionView防止多次輕擊/調用didSelectItemAt
- 3. viewForSupplementaryElementOfKind未在自定義UICollectionViewLayout上調用
- 4. 的iOS:UICollectionView實施viewForSupplementaryElementOfKind轟炸
- 5. UICollectionView cellForItemAt第二次沒有調用
- 6. viewForSupplementaryElementOfKind不工作,因爲空數組的
- 7. 多次調用
- 8. UICollectionView單元格配置太多次
- 9. 自定義UICollectionViewLayout多次調用layoutAttributesForElementsInRect
- 10. didUpdateToLocation多次調用
- 11. Overlay.draw()多次調用
- 12. Android:OnPrimaryClipChangedListener()多次調用
- 13. 多次調用ReactDOM.render
- 14. onReceive多次調用
- 15. sliderValueDidChange多次調用
- 16. 多次調用MouseListener
- 17. InitWithCoder多次調用
- 18. GetView調用多次
- 19. 多次調用setcontentview?
- 20. ABAddressBookRegisterExternalChangeCallback多次調用
- 21. 多次調用registerUserNotificationSettings
- 22. 多次調用startforeground?
- 23. 多次調用GCE
- 24. onPerformSync()多次調用
- 25. OnPrimaryClipChangedListener多次調用
- 26. 多次調用malloc
- 27. 多次調用CryptHashData
- 28. observeValueForKeyPath多次調用
- 29. ON_EN_KILLFOCUS多次調用
- 30. 多次調用xively.feed.history()
它是根據你的部分稱爲數 –
是否有任何解決方案停止調用一個以上的時間? –
哈哈哈,然後做喜歡,設置一個部分,並添加另一個東西是行 –