Sagar
Sagar

Reputation: 1304

different frame for each cell of UICollectionView

what I want to do is,

I am using UICollectionView to show my stuff.

What I want is, the stuff that I want to show is coming from server, It may be in single line or some may be multiple.

I wanted to show the cell frame of UICollectionView differently. Means If data is big then bigger frame of UICollectionViewcell and if data is less then smaller frame of UICollectionViewcell.

I tried a lot, but I am succeed only in having fixed size of frame for UICollectionViewcell

How to achieve different frame for each cell according to need.

Is it possible....?

@note :- I am not using any xib. All is done programatically.

Upvotes: 0

Views: 121

Answers (1)

CRDave
CRDave

Reputation: 9285

It seem like you are getting UICollectionView wrongly.

Let me say in short You are not suppose to set frame but you need to implement your own UICollectionViewLayout.

By default UICollectionView use UICollectionViewFlowLayout. Which add cell one by one.

But UICollectionView is very power full UI component than that. To open its true power you have to understand UICollectionViewLayout.

Here are some good example of that :

If you want to learn how to create your ow than have a look at following link:

If you need to know overview of how UICollectionView work than read : NSHipster:UICollection​View
One in depth look in Custom Collection View Layouts : objc : Custom Collection View Layouts

I hope I get u correctly. And this will lead you to right direction.

Upvotes: 1

Related Questions