6

ここに画像の説明を入力してくださいここに画像の説明を入力してくださいGMGridViewを使用しているときに、奇妙な問題が発生しました。実際、私はGMGridviewを使用してレストランのテーブルを表示しています。Table1(最初のセルを意味する)を選択した場合、redColor(つまり、占有されているテーブル)に変更する必要があります。私はこれを行いましたが、私の問題は、セル1(redcolor)を選択すると、GMGridviewを使用したすべてのクラスでそのredcolorが表示されることです。それは完全に間違っています。別のクラスで選択がないと、選択されたものとして表示されます。

下の画像では、1を選択すると、7も選択されています。

そして私のコードは

- (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index{



    CGSize size = [self GMGridView:gridView sizeForItemsInInterfaceOrientation:[[UIApplication 
sharedApplication] statusBarOrientation]];


    GMGridViewCell *cell = [gridView dequeueReusableCell];


    int isOccupied = [[[self.arrayOfoccupiedTables objectAtIndex:index] objectForKey:@"TStatus"] intValue];


    if (!cell)

    {

        cell = [[[GMGridViewCell alloc] init] autorelease];


        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];

        cell.contentView = view;

    }


    [[cell.contentView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];


    UILabel *label = [[UILabel alloc] initWithFrame:cell.contentView.bounds];

    label.autoresizingMask = UIViewAutoresizingFlexibleWidth | 

UIViewAutoresizingFlexibleHeight;

    label.textAlignment = UITextAlignmentCenter;

    label.backgroundColor = [UIColor clearColor];

    label.font = [UIFont fontWithName:APPFONTLI size:22.0f];

    label.adjustsFontSizeToFitWidth = YES;



    if (isOccupied == 100001) {


        label.textColor = [UIColor whiteColor];

        label.highlightedTextColor = [UIColor blackColor];

        label.backgroundColor = [UIColor redColor];//redColor];

        //colorWithRed:43.0f/255.0f green:150.0f/255.0f blue:0.0f/255.0f alpha:1.0f];//GreenColor

        label.text  = [[self.filtredArray objectAtIndex:index] objectForKey:@"TableName"];


    }else if(isOccupied == 100002) {



        label.textColor = [UIColor whiteColor];

        label.highlightedTextColor = [UIColor blackColor];

        label.backgroundColor = [UIColor colorWithRed:43.0f/255.0f green:150.0f/255.0f 
blue:0.0f/255.0f alpha:1.0f];

        //colorWithRed:215.0f/255.0f green:215.0f/255.0f blue:0.0f/255.0f alpha:1.0f];//GreenColor

        label.text  = [[self.filtredArray objectAtIndex:index] objectForKey:@"TableName"];

    }

    else if(isOccupied == 100003) {

        label.textColor = [UIColor blackColor];

        label.highlightedTextColor = [UIColor whiteColor];

        label.backgroundColor = [UIColor colorWithRed:215.0f/255.0f green:215.0f/255.0f blue:0.0f/255.0f alpha:1.0f];// Yellow Color


        //colorWithRed:229.0f/255.0f green:229.0f/255.0f blue:229.0f/255.0f alpha:1.0f];//GrayColor

        label.text  = [[self.filtredArray objectAtIndex:index] objectForKey:@"TableName"];

    }
    [cell.contentView addSubview:label];
    return cell;
}

- (void)GMGridView:(GMGridView *)gridView didTapOnItemAtIndex:(NSInteger)position
{

  NSLog(@"Did tap at index %d", position);

    [[SoundManager sharedSoundManager] playSound:SELECTED];

    //[self performSelector:@selector(registerTableToTheServer:) withObject:nil afterDelay:0.2];

    [self registerTableToTheServer:[[self filtredArray] objectAtIndex:position]];

    NSInteger tableId   =  [[[[self filtredArray] objectAtIndex:position] objectForKey:@"Table_id"] intValue];

    [self createPlistWithTableId:tableId];

    [_gmGridView reloadData];
}

そして、viewWillAppearとviewDidLoadでもグリッドビューをリロードしています。役に立つものは何も見つかりませんでした。みんな助けてください。

4

1 に答える 1

6
- (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index{
    
    CGSize size = [self GMGridView:gridView sizeForItemsInInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
    
    GMGridViewCell *cell = [gridView dequeueReusableCell];
    int isOccupied = [[[self.arrayOfoccupiedTables objectAtIndex:index] objectForKey:@"TStatus"] intValue];

    if (!cell)  {
        cell = [[[GMGridViewCell alloc] init] autorelease];
             
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
        cell.contentView = view;
    }

   //TRY TO RELOAD THE MG_GRIDVIEW HERE
}
于 2012-10-25T13:08:09.670 に答える