0

こんにちは皆さん、

のセルにもう1つのビューを追加する必要がありGMGridViewます。しかし、ラベルをビューからにドラッグする必要があるため、これを行うことができませんview1

私のコードは:

- (GMGridViewCell *)GMGridView:(GMGridView *)gridView1 cellForItemAtIndex:(NSInteger)index
        {
        // set size based on orientation

        CGSize size = [self GMGridView:gridView sizeForItemsInInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
        GMGridViewCell *cell = [gridView dequeueReusableCell];
        if (!cell)
        {
                cell = [[[GMGridViewCell alloc]init]autorelease];

//one view
                UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
                view.backgroundColor = [UIColor redColor];
                view.layer.masksToBounds = NO;
                view.layer.cornerRadius = 2;
                cell.contentView = view;

//another view
            UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 80, size.width, size.height)];
            view1.backgroundColor = [UIColor yellowColor];
            view1.layer.masksToBounds = NO;
            view1.layer.cornerRadius = 2;
            cell.contentView = view1;
        }
        [[cell.contentView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];

        // allocate label
        UILabel *label = [[UILabel alloc] initWithFrame:cell.contentView.bounds];
        label.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        label.text = (NSString *)[self.currentData objectAtIndex:index];
        label.textAlignment = UITextAlignmentCenter;
        label.backgroundColor = [UIColor clearColor];
        label.textColor = [UIColor blackColor];
        label.font = [UIFont boldSystemFontOfSize:20];
        [cell.contentView addSubview:label];
        return cell;
    }

セルの高さは200ですが、それでも1つのビューしか表示されません。

4

1 に答える 1