xcode UICollection查看打开另一个视图控制器

时间:2013-03-02 10:36:20

标签: ios xcode uiviewcontroller

我有一个UICollectionViewController并且已经在单元格中显示图像,因为我点击/点击特定图像,“推送”到正常的ViewController。我怎么做?这是我到目前为止的代码...... 想在其他视图控制器中打开所选图像,请帮忙

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return [imagearray count];
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier=@"Cell" ;
    customcell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
    [[cell nyimage]setImage:[UIImage imageNamed:[imagearray objectAtIndex:indexPath.item]]];
    return cell;

}

1 个答案:

答案 0 :(得分:2)

您可以像这样实现委托方法:

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    DetailViewController* viewController = [[DetailViewController alloc] init];
    //configure detail view controller
    // viewController.detailInfo = ...
    [self.navigationController pushViewController:viewController animated:YES];
}