Search code examples
iosgmgridview

GMGridView cells scroll upto the statusbar in iOS 7


I have a UIViewController that I am setting as the rootviewcontroller of a UINavigationController. Then in the viewcontroller I create a gmgridview like so:

NSInteger spacing = 15;

GMGridView *gmGridView = [[GMGridView alloc] initWithFrame:self.view.bounds];
gmGridView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

[self.view addSubview:gmGridView];
_gmGridView = gmGridView;

_gmGridView.style = GMGridViewStyleSwap;
_gmGridView.itemSpacing = spacing;
_gmGridView.minEdgeInsets = UIEdgeInsetsMake(spacing, spacing, spacing, spacing);
_gmGridView.centerGrid = YES;
_gmGridView.actionDelegate = self;
_gmGridView.sortingDelegate = self;
_gmGridView.transformDelegate = self;
_gmGridView.dataSource = self;

If I understand this correctly, according to the UI Guide for iOS7 if you use a UINavigationController, it automatically takes care of the view flowing under the statusbar. Which seems to work for the most part of it. Cuz if I do _gmGridView.backgroundColor = [UIColor blackColor]I can see that the gridview does not overflow underneath the statusbar. But when scrolling, the GMGridViewCells go underneath the status bar. I cannot understand why.

This image shows the gridview with the black background color. Notice that the statusbar background isn't black, which tells me that the gridview does not appear behind it.

enter image description here

And this one shows the scrolling

enter image description here


Solution

  • In iOS7 that statusbar is transparent. If you don't want things to appear behind the status bar, set the frame of the root view to be approx 30 from the top of the screen and make sure clipsToBounds = YES.

    GMGridView *gmGridView = [[GMGridView alloc] initWithFrame:CGRectMake(0,30,self.view.bounds.size.width,self.view.bounds.size.height-30)];