ios - Inserting the first cell into a collection view causes an assertion failure -


if try insert item uicollectionview when there 0 sections , 0 items, assertion failure.

*** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'invalid update: invalid number of sections. number of sections contained in collection view after update (1) must equal number of sections contained in collection view before update (0), plus or minus number of sections inserted or deleted (0 inserted, 0 deleted).'

a classic. problem is, i'm modifying data source , inserting item directly afterwards. showfirstcell property checked in of necessary data source methods , isn't modified anywhere else.

self.showfirstcell = true self.collectionview.insertitemsatindexpaths([nsindexpath(foritem: 0, insection: 0)]) 

wrapping in performbatchupdates changes nothing.

i item added in animated fashion. don't think should have first check if there items in place, doing , calling reloaddata instead work, it's not perfect.

your number of sections don't match up.

once have decided enter section uicollectionview, should return same number in numberofsections function well.

what's happening right insert cell, , calls numberofsections function again, still returning 0, , promptly crashes.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -