mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-06 06:58:26 +00:00
Add TEMP code to print the delegate class in the assert message
Summary: Trying to track down the causes of this assert. Unfortunately the assert does not tell us which class is returning the bad info. Add some HACKY TEMP code to print out the class name in some cases. Hopefully this will catch all the issues. I put the code in a static function called within the assert, so it should be compiled out of prod builds. Differential Revision: D31482081 fbshipit-source-id: bef0274c0e35b90d5f77b0cfd337e3f9a772e8b8
This commit is contained in:
parent
ad59a9ead3
commit
44c009b6fc
1 changed files with 19 additions and 2 deletions
|
|
@ -18,6 +18,7 @@
|
|||
#import "IGListCollectionViewDelegateLayout.h"
|
||||
|
||||
#import "UIScrollView+IGListKit.h"
|
||||
#import "IGListAdapter.h"
|
||||
|
||||
static CGFloat UIEdgeInsetsLeadingInsetInDirection(UIEdgeInsets insets, UICollectionViewScrollDirection direction) {
|
||||
switch (direction) {
|
||||
|
|
@ -459,6 +460,21 @@ static void adjustZIndexForAttributes(UICollectionViewLayoutAttributes *attribut
|
|||
|
||||
#pragma mark - Private API
|
||||
|
||||
- (NSString *)_classNameForDelegate:(id<UICollectionViewDelegateFlowLayout>)delegate sectionIndex:(NSInteger)section {
|
||||
NSString *const delegateClassString = NSStringFromClass(delegate.class);
|
||||
if ([delegateClassString isEqualToString:@"IGListAdapterProxy"] == NO) {
|
||||
return delegateClassString;
|
||||
}
|
||||
|
||||
id forwardingObject = [(id)delegate forwardingTargetForSelector:@selector(collectionView:layout:insetForSectionAtIndex:)];
|
||||
if ([forwardingObject isKindOfClass:IGListAdapter.class] == NO) {
|
||||
return NSStringFromClass([forwardingObject class]);
|
||||
}
|
||||
|
||||
id sectionController = [forwardingObject sectionControllerForSection:section];
|
||||
return NSStringFromClass([sectionController class]);
|
||||
}
|
||||
|
||||
- (void)_calculateLayoutIfNeeded {
|
||||
if (_minimumInvalidatedSection == NSNotFound) {
|
||||
return;
|
||||
|
|
@ -532,13 +548,14 @@ static void adjustZIndexForAttributes(UICollectionViewLayoutAttributes *attribut
|
|||
|
||||
IGAssert(CGSizeGetLengthInDirection(size, fixedDirection) <= paddedLengthInFixedDirection
|
||||
|| fabs(CGSizeGetLengthInDirection(size, fixedDirection) - paddedLengthInFixedDirection) < FLT_EPSILON,
|
||||
@"%@ of item %li in section %li (%.0f pt) must be less than or equal to container (%.0f pt) accounting for section insets %@",
|
||||
@"%@ of item %li in section %li (%.0f pt) must be less than or equal to container (%.0f pt) accounting for section insets %@. Delegate class: %@",
|
||||
self.scrollDirection == UICollectionViewScrollDirectionVertical ? @"Width" : @"Height",
|
||||
(long)item,
|
||||
(long)section,
|
||||
CGSizeGetLengthInDirection(size, fixedDirection),
|
||||
CGRectGetLengthInDirection(contentInsetAdjustedCollectionViewBounds, fixedDirection),
|
||||
NSStringFromUIEdgeInsets(insets));
|
||||
NSStringFromUIEdgeInsets(insets),
|
||||
[self _classNameForDelegate:delegate sectionIndex:section]);
|
||||
|
||||
CGFloat itemLengthInFixedDirection = MIN(CGSizeGetLengthInDirection(size, fixedDirection), paddedLengthInFixedDirection);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue