2012-11-04 104 views
0

当我从CollectionView中选择一个单元格(在popOver中)时,我的mainView中显示了一个图像(使用Storyboard和imageViews和CollectionViews)。UICollectionViews选择2个图像,一个在另一个上面

如何创建另一个(包含UiCollectionView的popover)让我选择图像并将第二个图像放在已显示的图像上?

回答

0
#pragma mark - UICollectionViewDataSource 

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView 
{ 
    // Return the number of sections. 
    // return [_carImages count]/2; 
    return 1; 
} 






- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 
{ 
    // Return the number of rows in the section. 
    return [_carImages count]; 
} 








- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 

    // CellTasteCollectionView *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; 
    // image = [[UIImage imageNamed:[_carImages objectAtIndex:indexPath.row]]; 
    // cell.imageView.image = image; 

    // return cell; 

    NSLog(@"INDEX PATH roe %@",[_carImages objectAtIndex:indexPath.row]); 

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; 
/* 




UIImageView *brickAnim = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile: imageFilePath]]; 
brickAnim.frame = CGRectMake(0, 0, 62, 57); 
[cell.contentView addSubview:brickAnim]; 
cell.layer.borderColor=[UIColor whiteColor].CGColor; 
cell.layer.borderWidth=2.0; 
    */ cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:[_carImages objectAtIndex:indexPath.row]]]; 
    return cell; 

    /* MyCollectionViewCell *myCell = [collectionView 
            dequeueReusableCellWithReuseIdentifier:@"MyCell" 
            forIndexPath:indexPath]; 

    UIImage *image; 
    int row = [indexPath row]; 

    image = [UIImage imageNamed:_carImages[row]]; 



    myCell.imageView.image = image; 

    return myCell;*/ 
} 







- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { 
    // UIImage *image =[UIImage imageNamed: [_carImages objectAtIndex:indexPath.row]]; 
    return CGSizeMake(40, 40); 
} 

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { 
    return UIEdgeInsetsMake(20, 20, 20, 20); 
} 




#pragma mark - 
#pragma mark UICollectionViewFlowLayoutDelegate 





/*-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UIImage *image; 
    int row = [indexPath row]; 

    image = [UIImage imageNamed:_carImages[row]]; 

    return image.size; 
}*/ 






- (void)selectItemAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UICollectionViewScrollPosition)scrollPosition{ 


} 
+0

该评论代码是有用的吗?或者OP应该忽略它? – nhahtdh

相关问题