Removing extra space at the top of uicollectionview
I have a xib where a button and a uicollectionview are displayed like this:
Now when I run it, it looks like this:
I want to remove the extra space above the photos. I want to show pictures just below the button. I also haven't added a header section to the xib. But, when I scroll up, the images move up and down under the buttton too.This means the frame starts from just below the button, but I get extra free space.
So, can anyone help me remove the extra space?
source to share
Add this code to your controller class
- (void)viewDidLoad
{
[super viewDidLoad];
self.automaticallyAdjustsScrollViewInsets = NO;
}
Here is a doc for automaticallyAdjustsScrollViewInsets
Default is YES, which allows the view controller to customize its scroll inserts in response to areas of the screen consumed by the status bar, navigation bar, toolbar, or tab bar. Set to NO if you want to control the scroll insertion settings yourself, for example, when there is more than one scroll in the view hierarchy.
source to share
I had the same problem. What a job for me was to set automaticallyAdjustsScrollViewInsets = NO
not only on the ViewController containing the CollectionView, but also on its parent ViewController, because the child ViewController was in the ContainerView.
This can also be done in the interface builder: Auto adjust scrolling in view mode