I have a requirement to create a view controller that behaves a lot like a webpage; if the user presses the button, the layout changes on-the-fly, and the press another button and it goes back to divisional layout. the first layout is like a table view, the second more like a collection view with a custom layout. is it possible to change a collection view layout on-the-fly? Heretofore I have only set the layout once and left it.
Asked
Active
Viewed 571 times
1 Answers
1
Yes, use the -setCollectionViewLayout:animated:
method.

jsd
- 7,673
- 5
- 27
- 47
-
use of setCollectionViewLayout is actually causing a bad access error – moop Jan 06 '16 at 23:39
-
@moop that suggests you are not keeping a reference to the collectionview object around. are you storing it in a strong @property? – jsd Jan 07 '16 at 18:18
-
yes definitely it is strong, as are the two layouts. the first layout is a flow layout and the second layout that causes a crash when I try to switch to it is a custom layout. – moop Jan 07 '16 at 21:52
-
Ugh... I found the problem. another programmer had used "hdr" instead of UICollectionElementKindSectionHeader. still that ought not result in a crash. – moop Jan 07 '16 at 21:58