UICollectionView-layout-update - Artikel-Größe nicht ändern

Ich habe ein problem mit collectionView Element Größe. Ich möchte Anzeige 3 Elemente in der Zeile für Hochformat, und 6 für die Landschaft. Ich habe -layoutSubviews wie diese:

- (void)layoutSubviews {
    [super layoutSubviews];

    if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait || ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown)) {
        //Portrait orientation
        self.flowLayoutPortrait.itemSize = CGSizeMake(106, 106);

    } else if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight)) {
        //Landscape orientation
        self.flowLayoutPortrait.itemSize = CGSizeMake(93, 93);
    }
    [self.collectionView.collectionViewLayout invalidateLayout];
}

Aber die Größe der Zelle wird nicht aktualisiert, es bleiben immer die gleichen für beide Ausrichtungen.
Wenn ich 2 flowLayouts und die Nutzung:

[self.collectionView setCollectionViewLayout:self.flowLayoutLandscape];

Alles funktioniert, aber ich weiß wirklich nicht, wie Sie geändert werden. Die Animation ist wirklich schlecht.
Und weil itemSize ist die einzige Eigenschaft, die aktualisiert werden muss, mit 1 layout scheint beste option.

Wie kann ich sagen collectionView zu aktualisieren-layout?

InformationsquelleAutor Armands L. | 2014-05-19

Schreibe einen Kommentar