Background:
My UICollectionView is defined in my MainStoryboard, with layout constraints to center it horizontally in the view.
In my initial view controller I give the user a choice of items to view in the next view (the UICollectionView).
Based on the content, I want to set the frame of the UICollectionView so that it changes width and height to accomodate the content chosen by the user.
For example, one view might require an 800x800 frame positioned at 560,160, and another may require a 1600x800 collectionView positioned at 160,160.
If I query the collectionview frame, I get the initial values based on the storyboard:
CGRect frame = self.myCollectionView.frame;
frame:: 560.0, 160.0, 800.0, 800.0If I try setting the frame:
CGRect frame = CGRectMake( 160.0, 160.0, 1600.0, 800.0 );
self.myCollectionView.frame = frame;The frame changes, but there is NO VISIBLE CHANGE to the collectionView on the screen.
I am able to modify the contentSize, and the itemSize within the flow to accomodate my different content cells, but there is no change on screen for the UIcollectionView itself.
I have tried things such as:
[self.myCollectionView setNeedsDisplay];
or
[self.myCollectionView setNeedsLayout];
or
[self.myCollectionView reloadData];If I query the frame after making the changes, the changes show correctly in the frame values, but no change appear on screen.
What am I missing?
How do I programmatically change the size and position on the screen?
Is there something I'm missing about how to manipulate the UICollectionView.
This is for a tvOS project I am working on. (Just in case, it works fine on iOS but not on tvOS)
If I cannot find a solution, I will likely have to re-code the entire view without using the storyboard.
At least there, I can use initWithFrame and create it at runtime. I just prefer to use storyboards if at all possible.
I am able to move and resize other views just fine. What's going on with UICollectionView?