I have a UICollectionView
and it works fine, but I want to add a few UICollectionViewCells
items programmatically into the collection view.
So how can I achieve this?
To further clarify: when I say programmatically I mean inserting a cell during runtime, when an action is fired, not when the app is loaded (using the viewDidLoad
method). I know when the model is updated and the call is made to UICollectionView
in the insertItemsAtIndexPaths:
method. It should create a new cells, but it's not doing that, it's throwing an error.
...By referring to UICollectionView documentation
From your Question: you can for example register A gesture Recognizer, and Insert a NEW cell by doing the following:
in
Here is how to insert an item in Swift 3 :
You must first update your data.
– insertItemsAtIndexPaths:
does the jobIf you are inserting multiple
items
intoUICollectionView
, you can useperformBatchUpdates: