Ios 目标C中uicollectionview中的标签覆盖

Ios 目标C中uicollectionview中的标签覆盖,ios,objective-c,uicollectionviewcell,Ios,Objective C,Uicollectionviewcell,请帮忙。。。 此代码超出了标签 cellForItemAtIndexPath static NSString *identifier = @"cellIdentifier"; [self.mycollectionViewOutlet registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellIdentifier"]; UICollectionViewCell *cell = [collectio

请帮忙。。。 此代码超出了标签

cellForItemAtIndexPath

 static NSString *identifier = @"cellIdentifier";

[self.mycollectionViewOutlet registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellIdentifier"];

 UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];

 cell.backgroundColor =[UIColor greenColor];

 self.mycollectionViewOutlet.backgroundColor=[UIColor redColor];

 objects_products * ob = [self.recipeImages objectAtIndex:indexPath.row];

 UILabel *recipelableView = (UILabel*)[cell.contentView viewWithTag:LABEL_TAG];

 if (!recipelableView)  

      recipelableView=[[UILabel alloc]initWithFrame:CGRectMake(50,115,100,50)];

      [recipelableView setFont:[UIFont fontWithName:@"HelveticaNeue" size:12]];

      recipelableView.textColor=[UIColor redColor];

      [recipelableView setText:ob.price];

      recipelableView.tag = LABEL_TAG;

      [cell addSubview:recipelableView];

  return cell;

也许这会对你们有所帮助,你们在单元格中添加了多次标签。请按如下方式将标签添加到条件(仅添加一次)的单元格中

static NSString *identifier = @"cellIdentifier";

[self.mycollectionViewOutlet registerClass:[UICollectionViewCell class]     forCellWithReuseIdentifier:@"cellIdentifier"];

 UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];

 cell.backgroundColor =[UIColor greenColor];

 self.mycollectionViewOutlet.backgroundColor=[UIColor redColor];

 objects_products * ob = [self.recipeImages objectAtIndex:indexPath.row];

 UILabel *recipelableView = (UILabel*)[cell.contentView viewWithTag:LABEL_TAG];

if (!recipelableView)   {
    recipelableView=[[UILabel alloc]initWithFrame:CGRectMake(50,115,100,50)]; 
   [recipelableView setFont:[UIFont fontWithName:@"HelveticaNeue" size:12]];

  recipelableView.textColor=[UIColor redColor];
  recipelableView.tag = LABEL_TAG;
  [cell addSubview:recipelableView];
}


  [recipelableView setText:ob.price];

  return cell;

也许这会对你们有所帮助,你们在单元格中添加了多次标签。请按如下方式将标签添加到条件(仅添加一次)的单元格中

static NSString *identifier = @"cellIdentifier";

[self.mycollectionViewOutlet registerClass:[UICollectionViewCell class]     forCellWithReuseIdentifier:@"cellIdentifier"];

 UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];

 cell.backgroundColor =[UIColor greenColor];

 self.mycollectionViewOutlet.backgroundColor=[UIColor redColor];

 objects_products * ob = [self.recipeImages objectAtIndex:indexPath.row];

 UILabel *recipelableView = (UILabel*)[cell.contentView viewWithTag:LABEL_TAG];

if (!recipelableView)   {
    recipelableView=[[UILabel alloc]initWithFrame:CGRectMake(50,115,100,50)]; 
   [recipelableView setFont:[UIFont fontWithName:@"HelveticaNeue" size:12]];

  recipelableView.textColor=[UIColor redColor];
  recipelableView.tag = LABEL_TAG;
  [cell addSubview:recipelableView];
}


  [recipelableView setText:ob.price];

  return cell;

你在用汤姆手机吗?你有什么问题?您粘贴在cellForItemAt中的代码也是?你在用汤姆手机吗?你有什么问题?您粘贴在cellForItemAt中的代码也是?