ios - UICollectionView remove whitespace/header iOS11 -


i have uicollection view looks (see 2 purple , blue borders):

uicollectionview issue

on ios 10 there no header/whitespace, on ios11 there is. i've tried mentioned here: how can enable/disable section headers in uicollectionview programmatically?

and code looks this:

- (void) viewdidload {     [super viewdidload];      autocompletelayout = [[sqlproautocompleteflowlayout alloc] init];     autocompletelayout.headerreferencesize = cgsizezero;      autocompletecollectionview = [[uicollectionview alloc] initwithframe: cgrectzero                                                     collectionviewlayout: autocompletelayout];      autocompletecollectionview.insetslayoutmarginsfromsafearea = no;      [self.view addsubview: autocompletecollectionview];      // removed layout code (leftanchor, rightanchor, topanchor, bottomanchor).      autocompletecollectionview.delegate = self;     autocompletecollectionview.datasource = self;      // removed nib register code      self.view.layer.bordercolor = [uicolor redcolor].cgcolor;     self.view.layer.borderwidth = 1;      autocompletecollectionview.layer.bordercolor = [uicolor bluecolor].cgcolor;     autocompletecollectionview.layer.borderwidth = 2; }  - (cgsize) collectionview: (uicollectionview *) collectionview                    layout: (uicollectionviewlayout *) collectionviewlayout referencesizeforheaderinsection:(nsinteger)section {     return cgsizezero; }  - (cgsize)collectionview:(uicollectionview *)collectionview                   layout:(uicollectionviewlayout *)collectionviewlayout referencesizeforfooterinsection:(nsinteger)section {     return cgsizezero; } 

and flowlayout looks this:

- (void) setuplayout {     self.minimuminteritemspacing = 0;     self.minimumlinespacing      = 0;     self.scrolldirection         = uicollectionviewscrolldirectionvertical; } // end of setuplayout  - (void) preparelayout {     [super setitemsize: [self itemsize]];     [super setsectioninset: [self sectioninset]];     self.minimumlinespacing = 0;      [super preparelayout]; } // end of preparelayout  - (cgfloat) itemwidth {     return self.collectionview.frame.size.width; }  - (cgsize) itemsize {     cgsize result = cgsizemake(self.collectionview.frame.size.width,                                rowheight);      return result; }  - (void) setitemsize:(cgsize)itemsize {     self.itemsize = cgsizemake(self.collectionview.frame.size.width,                                rowheight); }  - (cgpoint) targetcontentoffsetforproposedcontentoffset:(cgpoint)proposedcontentoffset {     return cgpointzero; } 

i have verified uicollectionview's contentinset zero'd out.

what missing? why uicollectionview still have whitespace?

in ios 11, there have been changes uiscrollview.

try setting contentinsetadjustmentbehavior property

collectionview.contentinsetadjustmentbehavior = uiscrollviewcontentinsetadjustmentnever; 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -