Ios UICollectionView不考虑布局
我想在旋转后更改集合视图布局,以更改单元格大小。在模拟器中工作得很好。在iphone6上没有 代码如下:Ios UICollectionView不考虑布局,ios,uicollectionview,uicollectionviewlayout,viewdidlayoutsubviews,Ios,Uicollectionview,Uicollectionviewlayout,Viewdidlayoutsubviews,我想在旋转后更改集合视图布局,以更改单元格大小。在模拟器中工作得很好。在iphone6上没有 代码如下: -(void)viewDidLoad { UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; self.collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds c
-(void)viewDidLoad {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
self.collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
[_collectionView registerClass:[TLListCell class] forCellWithReuseIdentifier:kTLAsyncListCell];
_collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_collectionView.contentInset = UIEdgeInsetsMake(LIST_GAP, LIST_GAP, LIST_GAP, LIST_GAP);
_collectionView.backgroundColor = [UIColor clearColor];
_collectionView.dataSource = self;
_collectionView.delegate = self;
UIRefreshControl *refreshControl = [self reportRefreshControl];
[_collectionView addSubview:refreshControl];
[self.view addSubview:_collectionView];
}
-(void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
layout.itemSize = CGSizeMake(20, 20);
[self.collectionView setCollectionViewLayout:layout animated:YES completion:nil];
// collection view doesn't respect this layout
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
// not called after changing the layout!!!
}
我目前也遇到了类似的问题。我的问题是。你找到解决办法了吗?非常感谢您的帮助:)