【发布时间】:2014-03-14 19:03:40
【问题描述】:
我已经连续遇到这个问题大约 3 个小时了,我正要把我的 Mac 扔到房间的另一边。
所以基本上,我正在尝试将 UIImage 传递给另一个视图控制器。我有设置,所以当用户点击其中一个 UIColectionViewCells 时,它会将它们发送到具有全屏 UIImageView 的另一个视图。我似乎无法弄清楚如何将 UIImage 从 ViewController1 获取到 ViewController2。
这是我的一些代码。请记住,我正在尝试将这个 UIImage selectedImage 从 VC1 获取到 VC2。
collectionView cellForItemAtIndexPath
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = @"GalleryCell";
GalleryCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
[cell.layer setBorderWidth:2.0f];
[cell.layer setBorderColor:[UIColor whiteColor].CGColor];
[cell.layer setCornerRadius:5.0f];
UIImage *usingImage = [imageArray objectAtIndex:indexPath.row];
UIImageView *imageView = [[UIImageView alloc] initWithImage:usingImage];
imageView.tag = 100;
imageView.frame = CGRectMake(0, 0, cell.bounds.size.width, cell.bounds.size.height);
[cell addSubview:imageView];
return cell;
}
collectionView didSelectItemAtIndexPath
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *selectedCell = [collectionView cellForItemAtIndexPath:indexPath];
UIImage *selectedImage = (UIImage *)[selectedCell viewWithTag:100];
[self performSegueWithIdentifier:@"GotoDetail" sender:nil];
}
【问题讨论】:
-
什么时候崩溃?你能告诉我们吗?请耐心等待。这不是一个很大的任务。
标签: ios objective-c uiimage uicollectionview unrecognized-selector