ios - UICollectionView embed in a UINavigationController,but the UICollectionViewCell frame is wrong -
i have uinavigationcontroller control 2 viewcontrollers,vc1 , vc2.
the pic shows vc2. , there has uicollectionview vc2.view's subview,also there has uicollectioncell embed in uicollectionview ,as can see below.
but when push vc1 vc2 ,the uicollectioncell's frame not correct. code write :
//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 frame of cell (0,-32,320,568) in initwithframe:(cgrect)frame:
//collectioncell.m -(id)initwithframe:(cgrect)frame{ self = [super initwithframe:frame]; } return self; }
what's wrong me?
try resize subviews after init it. developer library says:
layoutsubviews - implement method if need more precise control on layout of subviews either constraint or autoresizing behaviors provide.
use
-(void)layoutsubviews
Comments
Post a Comment