Lasang Lasang - 1 year ago 89
iOS Question

Removing extra space at top of uicollectionview

I have xib in which button and uicollectionview appears as follows:

enter image description here

Now, when I run it , it appears as follows:

enter image description here

I want to remove white space above photos. I want to show photos just below from button. I have not marked header section in xib too. But, when I scroll up, the images move upto just below buttton too.This means frame is starting from just below button, but, I am getting extra white space.

So, can anybody help me to remove extra white space?

Answer Source

Add this code to your Controller class

- (void)viewDidLoad 
    [super viewDidLoad];  
    self.automaticallyAdjustsScrollViewInsets = NO;

Here is doc for automaticallyAdjustsScrollViewInsets
Default value is YES, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar. Set to NO if you want to manage scroll view inset adjustments yourself, such as when there is more than one scroll view in the view hierarchy.