Add method to check if method is overriden on layout subclass

This commit is contained in:
Gregory John Casamento 2022-12-01 08:55:50 -05:00
parent af643cc821
commit cb8e805d0d

View file

@ -72,6 +72,39 @@ static NSCollectionViewSupplementaryElementKind GSNoSupplementaryElement = @"GS
*/
static NSString *_placeholderItem = nil;
@interface NSObject (CollectionViewInternalPrivate)
/**
* This method is used to determine if the receiver overrides the
* given selector.
*/
- (BOOL) overridesSelector: (SEL)s;
@end
@implementation NSObject (CollectionViewInternalPrivate)
- (BOOL) overridesSelector: (SEL)s
{
Class osc = [self superclass];
BOOL overriden = NO;
while(osc != nil)
{
overriden = ([self methodForSelector: s] != [osc instanceMethodForSelector: s]);
if (overriden)
{
break;
}
osc = [osc superclass];
}
return overriden;
}
@end
@interface NSCollectionView (CollectionViewInternalPrivate)
- (void) _initDefaults;
@ -1779,17 +1812,23 @@ static NSString *_placeholderItem = nil;
ps.height = (h > ps.height) ? h : ps.height;
}
// Get the size proposed by the layout...
if ([_collectionViewLayout overridesSelector: @selector(collectionViewContentSize)])
{
ps = [_collectionViewLayout collectionViewContentSize];
}
else
{
NSLog(@"%@ does not override -collectionViewContentSize, some items may not be shown", _collectionViewLayout);
}
cf.size = ps;
[self _setFrameWithoutTile: cf];
}
- (void) reloadData
{
if (_allowReload == NO)
{
return;
}
else
if (_allowReload)
{
NSInteger ns = [self numberOfSections];
NSInteger cs = 0;