I have a UINavigationController to control two ViewControllers,VC1 and VC2.
The pic shows is VC2. And there has a UICollectionView as a VC2.view's subview,also there has a UICollectionCell embed in UICollectionView ,as you can see below.
But When I push from VC1 to VC2 ,the UICollectionCell's frame is not correct. The code I write is :
//VC2.m
UICollectionViewFlowLayout *l = [[UICollectionViewFlowLayout alloc]init];
l.itemSize = CGSizeMake(self.bounds.size.width, self.bounds.size.height);
l.minimumLineSpacing = 6.0f;
l.sectionInset = UIEdgeInsetsMake(0, 0, 0, 6.0);
l.scrollDirection = UICollectionViewScrollDirectionHorizontal;
UICollectionView *parallaxCollection = [[UICollectionView alloc]initWithFrame:frame collectionViewLayout:l];
[parallaxCollection registerClass:[CollectionCell class] forCellWithReuseIdentifier:@"CollectionCell"];
[self addSubview:parallaxCollection];
And what I get the frame of cell is (0,-32,320,568) in the initWithFrame:(CGRect)frame:
//CollectionCell.m
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
}
return self;
}
What's wrong with me?