How to start UICollectionView and then add layout constraint to it

I noticed that there is only one method for initialization UICollectionView

:

- (instancetype)initWithFrame:(CGRect)frame
         collectionViewLayout:(UICollectionViewLayout *)layout

      

But right now, I want to use autoscale to accommodate this collection view. But that already gave the frame. Will it work if I add a layout constraint?

I am adding this collection view as a subtitle of a custom keyboard that has a subclass of the view class from UIInputViewController

. I have an NSLog custom keyboard view frame. I get a border: {0,0}, {0,0} and borders: {0, -30}, {0.30}. Why am I receiving these values? I do not understand. As these values ​​are not valid, so if I assign self.bounds to initialize the collection view. It won't work. So the question is how to add UICollectionView

to the custom keyboard and place it correctly?

+3


source to share





All Articles