1

我有一个显示图像的UICollectionView内部。UITableviewCell所有图像都显示得很好。我想对其进行设置,以便当您点击图像单元格时,它会执行一个 segue,将图像显示在UIViewController. 在我准备 segue 方法中,未设置图像单元格的索引。尽管单击了不同的图像单元格,但仅传递了第一个单元格(索引 0)。做了一些研究,但我发现的只是这个链接..

http://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell

它帮助我理解问题在于确保UICollectionView理解它UIViewController是它的代表,而不是UITableViewCell我从中得到的一切......不知道该怎么做。任何帮助是极大的赞赏。提前致谢

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if([segue.identifier isEqualToString:@"showPhoto"])
    {
        NSIndexPath *indexPath = [[self.collectionView indexPathsForSelectedItems] lastObject];

        if([segue.destinationViewController respondsToSelector:@selector(setImage:)])
        {
            _currentItem =[_photoItems objectAtIndex:indexPath];

            [segue.destinationViewController performSelector:@selector(setImage:) withObject:_currentItem];
        }
    }
}
4

0 回答 0