Trying to get Compositional Layout working (in Obj-C: legacy code base, legacy dev) with CollView in StoryBoard. Keep getting this error:
> 'Invalid section definition. Please specify a valid section definition when content is to be rendered for a section. This is a client error.'
Looking at the Code Sample I cannot see what I'm doing differently. Here is the code.
> 'Invalid section definition. Please specify a valid section definition when content is to be rendered for a section. This is a client error.'
Looking at the Code Sample I cannot see what I'm doing differently. Here is the code.
Code Block objective-c @implementation TemplatePickerCompLayout - (UICollectionViewCompositionalLayout*)initWithCoder:(NSCoder *)coder{ self = [super initWithCoder:coder]; self.collectionView.collectionViewLayout = [self createStandardCompLayout]; return self; } - (UICollectionViewLayout*)createStandardCompLayout{ NSCollectionLayoutSize* itemSize = [NSCollectionLayoutSize sizeWithWidthDimension:[NSCollectionLayoutDimension fractionalWidthDimension:1.0] heightDimension:[NSCollectionLayoutDimension fractionalHeightDimension:1.0]]; NSCollectionLayoutItem* item = [NSCollectionLayoutItem itemWithLayoutSize:itemSize]; item.contentInsets = NSDirectionalEdgeInsetsMake(5.0f, 5.0f, 5.0f, 5.0f); NSCollectionLayoutSize* groupSize = [NSCollectionLayoutSize sizeWithWidthDimension:[NSCollectionLayoutDimension fractionalWidthDimension:0.80] heightDimension:[NSCollectionLayoutDimension absoluteDimension:120.0f]]; NSCollectionLayoutGroup* group = [NSCollectionLayoutGroup horizontalGroupWithLayoutSize:groupSize subitem:item count:1]; group.contentInsets = NSDirectionalEdgeInsetsMake(10.0f, 30.0f, 10.0f, 30.0f); NSLog(@"Group:\n%@",group.visualDescription); UICollectionViewLayout* rtnLayout = [[UICollectionViewCompositionalLayout alloc]initWithSectionProvider:^NSCollectionLayoutSection * _Nullable(NSInteger section, id<NSCollectionLayoutEnvironment> _Nonnull env) { NSLog(@"env:%@ [%zd]",env,section) NSCollectionLayoutSection* sectionDef = nil; if (section == 0) { sectionDef = [NSCollectionLayoutSection sectionWithGroup:group]; sectionDef.contentInsets = NSDirectionalEdgeInsetsMake(10.0f, 10.0f, 10.0f, 10.0f); } else { sectionDef = [NSCollectionLayoutSection sectionWithGroup:group]; sectionDef.contentInsets = NSDirectionalEdgeInsetsMake(10.0f, 50.0f, 10.0f, 50.0f); } return sectionDef; }]; return rtnLayout; } @end