2014-04-14 28 views
0

cell.selectedbackgroundview不起作用。我发现selectedview被放置在单元格后面的图像中,导致没有可见的图像(我通过将图像变小然后看到图像后面的勾号来解决这个问题)。有没有办法来解决这个问题?我的代码似乎罚款必须有事情做与层Cell.selectedBackgroundview不显示

static NSString *identifier = @"Cell"; 

UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; 
UIImageView *productImages = (UIImageView *)[cell viewWithTag:100]; 
productImages.image = [UIImage imageNamed:[AllProducts_Sections[indexPath.section]objectAtIndex:indexPath.row]]; 


collectionView.backgroundColor = [UIColor greenColor]; 


cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tick 1.png"]]; 
collectionView.allowsMultipleSelection = YES; 
return cell 

As you can see the blue is the selected backgroundview and the blackbox is the image why doesnt the selectedbackgorundview go over the black box

+0

对不起,你不知道你想做什么。 – AMohan

+0

@Mohan此刻我的cell.selectedbackgroundview位于单元格后面的图像中,无法看到它。我希望它在前面,所以我可以看到它 – user2845489

+0

你想在你的图像顶部的transperent刻度标记? – AMohan

回答

0
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString * cellIdentifier = @"Cell"; 
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
    if (cell==nil) 
    { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 
    //some code 
    } 
    UIView *selectedBackView=[[UIView alloc]initWithFrame:cell.bounds]; 
    UIImageView *selectionImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tick 1.png"]]; 
    [selectedBackView addSubview:selectionImg]; 
    cell.selectedBackgroundView=selectedBackView; 
    return cell; 
} 

另外,还要确保蜱1.png是在项目的包。