【发布时间】:2015-10-11 11:16:12
【问题描述】:
当我将图像从 UICollectionViewController 发送到另一个 ViewController 时,这里是 View A:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"Detail Segue"])
{
PhotoDetailViewController *PhotoDetailVC = segue.destinationViewController;
NSIndexPath *path = [[self.collectionView indexPathsForSelectedItems] lastObject];
Photo *selectedPhoto = self.photos[path.row];
PhotoDetailVC.photo = selectedPhoto;
}
}
我在 ViewController(视图 B)中使用:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.imageView.image= self.photo.image;
}
【问题讨论】:
-
到底是什么问题?什么是预期的,但没有奏效?
-
当我按下 UICollectionViewCell 时,应用程序没有响应,它应该与 View B @Mahmoud Adam
-
那么你在哪里执行你的segue?您是否配置了集合视图的委托?你能在
collectionView:didSelectItemAtIndexPath:方法中显示你的代码吗 -
我在 UIcollectionViewController(视图 A)中执行我的 segue 我不使用 'collectionView:didSelectItemAtIndexPath:' 方法 @Mahmoud Adam
-
您可以编辑帖子并添加此代码,因为它可能有问题
标签: ios objective-c uiviewcontroller uicollectionview segue