【发布时间】:2016-04-22 22:09:58
【问题描述】:
我有一个显示 5 个单元格的 collectionView。现在我想要完成的是,例如,如果我点击第一个单元格,则下一个单元格的 imageView 是 imageOne,如果我点击第二个单元格,则 imageView 将是 imageTwo。在详细视图控制器中。
我正在努力做到这一点。这是我到目前为止所做的 在 UIView 控制器中的 prepareFor Segue 中,上面有一个 UiCollectionView
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:@"MainPush"]){
NSIndexPath *indexPath = [self.collectionView.indexPathsForSelectedItems objectAtIndex:0];
NSLog(@"%li", indexPath.row);
// Getting the collectionView cell in the destination class
if(indexPath.row == 0){
DetailCollectionViewCell *cell = [[DetailCollectionView alloc] init];
cell.imageView.image = [UIImage imageNamed: @"Thailand"];
}
}
}
我点击这个单元格,它会像这样转到另一个 collectionView,但我希望所选 collectionView 中的图像根据所选的 indexpath.row 有所不同。
我这样做了,但什么也没发生
【问题讨论】:
-
您是否尝试将图像传递给详细视图控制器?换句话说,当一个单元格被选中时,你是否试图转到另一个视图控制器?
标签: ios objective-c cocoa-touch uicollectionview