Ich habe eine Sammlung Ansicht Umbruch von UIView, die Sammlung Ansicht hat die gleichen Grenzen mit Wrapper-Ansicht. Die Datenquelle für die Sammlungsansicht wird geändert, sodass die Grenzen für die Wrapperansicht ebenfalls geändert werden. Ich habe die Wrapper-Sicht intrinsicContentSize
Methode mit collectionView.collectionViewLayout.collectionViewContentSize
implementiert, und die Sammlung Ansicht Layout ist Unterklasse von UICollectionViewFlowLayout
, die Zelle der UICollectionView hat auch Methode intrinsicContentSize
implementieren, aber die Wrapper-Ansicht Frame mit Sammlung Ansicht Inhalt Größe nicht aktualisiert. collectionViewContentSize
ist immer CGRectZero
. Ich habeUICollectionView wrapper view Rahmenupdate
[self.layout invalidateLayout];
[self.collectionView reloadData];
[self.collectionView layoutIfNeeded];
aber hat nicht funktioniert, Was soll ich den Wrapper Ansicht Rahmen mit collectionView.collectionViewLayout.collectionViewContentSize
aktualisieren tun.
einig Codes Es ist unten:
ZXCollectionViewWrapperView *wrapperView = [[ZXCollectionViewWrapperView alloc] init];
[self.view addSubview:wrapperView];
[wrapperView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.view);
}];
self.wrapperView = wrapperView;
/// wrapper view size
- (CGSize)intrinsicContentSize {
return self.collectionView.collectionViewLayout.collectionViewContentSize;
}
ZXCollectionViewAlignedLayout *layout = [[ZXCollectionViewAlignedLayout alloc] init];
self.layout = layout;
ZXCollectionView *collectionView = [[ZXCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
collectionView.dataSource = self;
collectionView.delegate = self;
collectionView.backgroundColor = [UIColor lightGrayColor];
[self addSubview:collectionView];
[collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
self.collectionView = collectionView;
[self.collectionView zx_registerCellClass:[ZXCommendCell class]];
self.dataSource = dataSource;
[self.collectionView reloadData];
[self.collectionView layoutIfNeeded];
Ich möchte die Wrapper-Ansicht Größe von UICollectionView contentSize anpassen, wie UILabel mit Wrapper-Ansicht. (UIlLabel mit Wrapper-Ansicht hat funktioniert, habe ich versucht). – jacinzhang
Sie können dies nicht mit der Sammlungsansicht tun, da es sich um eine Bildlaufansicht handelt – dduyduong