iphone – GMGridView的选择是最重要的

iphone – GMGridView的选择是最重要的,第1张

概述我使用GMGridView时遇到了奇怪的问题.其实我用GMGridview来展示餐厅餐桌.如果我选择Table1(这意味着第一个单元格),它应该更改为redColor(这意味着它是被占用的表).我做了这个,但我的问题是当我选择一个单元格1(红色)时,所有类别中都会显示红色,而不管我使用GMGridview.这是完全错误的,没有在另一个类中进行任何选择,它显示为选定的一个. 在下面的图像中,如果我选 我使用GMGrIDVIEw时遇到了奇怪的问题.其实我用GMGrIDvIEw来展示餐厅餐桌.如果我选择table1(这意味着第一个单元格),它应该更改为redcolor(这意味着它是被占用的表).我做了这个,但我的问题是当我选择一个单元格1(红色)时,所有类别中都会显示红色,而不管我使用GMGrIDvIEw.这是完全错误的,没有在另一个类中进行任何选择,它显示为选定的一个.

在下面的图像中,如果我选择了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,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中重新加载grIDvIEw.我没有找到任何有用的东西.请帮帮我们.

解决方法
- (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,size.height)];        cell.contentVIEw = vIEw;    }   //TRY TO RELOAD THE MG_GRIDVIEW HERE}
总结

以上是内存溢出为你收集整理的iphone – GMGridView的选择是最重要的全部内容,希望文章能够帮你解决iphone – GMGridView的选择是最重要的所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1056967.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-25
下一篇2022-05-25

发表评论

登录后才能评论

评论列表(0条)

    保存