Błąd konsoli: UICollectionView musi zostać zainicjowany za pomocą parametru układu innego niż nil

jestem nowy wUICollectionView i śledzę samouczek, który znalazłem na Youtube, ale utknąłem na błędzie, którego nie mogę zrozumieć.

Po uruchomieniu aplikacji z tym kodem:

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {

        return 1;

    }

    -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {

        return [self.array count];

    }

    -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

        CollectionCell *aCell = (CollectionCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"myCell" forIndexPath:indexPath];

        aCell.title.text = self.array[indexPath.row];

        return aCell;

    }

    - (void)viewDidLoad
    {
        [super viewDidLoad];

        self.array = @[@"First", @"Second", @"Thirth", @"Fourth"];

    }

A w .h:

@property (strong, nonatomic) NSArray *array;

W konsoli otrzymuję następujący błąd:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'UICollectionView must be initialized with a non-nil layout parameter'

NIE korzystam z serii ujęć i stworzyłem kolekcję. Zobacz, co widzisz tutaj:

Czy ktoś ma jakieś pomysły, dlaczego otrzymuję ten błąd? Wszystko jest mile widziane!

edytować:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.array = @[@"First", @"Second", @"Thirth", @"Fourth"];

    [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"myCell"];

    UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
    [flow setItemSize:CGSizeMake(60, 60)];
    [flow setScrollDirection:UICollectionViewScrollDirectionVertical];

    [self.collectionView setCollectionViewLayout:flow];

}

questionAnswers(2)

yourAnswerToTheQuestion