Search code examples
iphonegmgridview

how to aovoid situation in which gridView is covering my uilabel now:iphone


What I am having right now is

View :
    1.UILabel :  show a text 
    2.A GMGridView : show a grid of views

The codes are

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        gridViewHolder.itemSpacing      =   SPACING;
        gridViewHolder.dataSource       =   self;
        gridViewHolder.actionDelegate   =   self;
    }
#pragma mark - GMGridViewDataSource
- (CGSize)GMGridView:(GMGridView *)gridView sizeForItemsInInterfaceOrientation:(UIInterfaceOrientation)orientation {
    return CGSizeMake(WIDTH, HEIGT);     
}
- (NSInteger)numberOfItemsInGMGridView:(GMGridView *)gridView {
    return [needs count];
}
- (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index {
    cell                =   [gridView dequeueReusableCell];
    CGSize size         =   [self GMGridView:gridViewHolder sizeForItemsInInterfaceOrientation:UIInterfaceOrientationPortrait];

    if (!cell)
        cell            =   [[GMGridViewCell alloc] init];  

    UIView      *innerView                  =   [[UIView alloc] initWithFrame:CGRectMake(COOR_X, COOR_Y, size.width, size.height)];
    innerView.backgroundColor               =   [UIColor grayColor];

    cell.contentView                        =   innerView;
    return cell;
}

enter image description here

So now I can successfully to display a bunch of views in gridview. However, the content of the grid view will cover the label when I am scrolling the grid view. Below is the picture so that you can see my situation now enter image description here

How can avoid this situation so that whenever I scroll up my gridview, its contents wont be overlapped with my uilabel


Solution

  • Try this:

    gridview.clipsToBounds=TRUE;