Tôi đang hiển thị nhiều ô hình ảnh trong UICollectionView. Với một nút, tôi muốn có thể nhóm tất cả các ô của mình trong ô đầu tiên.UICollectionView: bố cục tùy chỉnh hoạt ảnh
Điều này hoạt động tốt nhưng khi tôi đang cố gắng thêm hoạt ảnh chuyển tiếp vào hoạt động nhóm của tôi, không có gì xảy ra.
Đây là phương pháp tôi sử dụng trong một bố cục tùy chỉnh:
- (NSArray*)layoutAttributesForElementsInRect:(CGRect)rect
{
NSArray* allAttributesInRect = [super layoutAttributesForElementsInRect:rect];
if([allAttributesInRect count] > 0 && _isRegroup)
{
UICollectionViewLayoutAttributes *firstAttribute = [allAttributesInRect objectAtIndex:0];
CGRect frame = firstAttribute.frame;
for(UICollectionViewLayoutAttributes *attribute in allAttributesInRect)
[UIView animateWithDuration:0.3f animations:^{attribute.frame = frame;}];
}
return allAttributesInRect;
}
- (void)regroupCells:(BOOL)isRegroup // This method is called from my collection controller when my button is pressed
{
_isRegroup = isRegroup;
[self invalidateLayout];
}
Bất kỳ ý tưởng? Cảm ơn!
Cảm ơn! Tôi hiểu nó hoạt động như thế nào :) – Pierre
Đây là kết quả cho những ai muốn xem :) http://d.pr/v/QUTF (Tôi có vấn đề trục trặc) – Pierre
Bạn cần tăng chỉ số z cho "đầu "mục trong ngăn xếp, bạn có thể làm điều đó trong cùng một vị trí khi bạn điều chỉnh khung. – jrturton