sorncc
sorncc

Reputation: 45

Collectionview contentSize wrong

I'm currently developing an app using UICollectionView. I need to know the height of the contentSize, which I'm doing by

self.collectionView.collectionViewLayout.collectionViewContentSize.height

Now this is working, but the returned value is not correct for portrait mode always. What should I do to achieve what I need?

Upvotes: 2

Views: 4858

Answers (1)

LE SANG
LE SANG

Reputation: 11005

Just get self.collectonView.contentSize in viewDidAppear and didRotateFromInterfaceOrientation

- (void)viewDidAppear:(BOOL)animated{
     NSLog(@"%0.0f-%0.0f",self.collectionView.contentSize.width,self.collectionView.contentSize.height);
}

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
    NSLog(@"%0.0f-%0.0f",self.collectionView.contentSize.width,self.collectionView.contentSize.height);
}

Upvotes: 3

Related Questions