[英]How to show view controller when clicking on CollectionViewCell INSIDE a UITableViewCell
I have a custom UITableViewCell that has a CollectionView with many collectionViewCells. 我有一个自定义UITableViewCell,它有一个带有许多collectionViewCells的CollectionView。
Xcode crashes when I click on each CollectionViewCell. 单击每个CollectionViewCell时Xcode崩溃。
Thid code is in the CustomTableViewCell.m file 这些代码位于CustomTableViewCell.m文件中
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
JTSImageInfo *imageInfo = [[JTSImageInfo alloc] init];
imageInfo.imageURL = [[NSURL alloc] initFileURLWithPath:[self.fullSizeImagePath objectAtIndex:indexPath.item]];
imageInfo.referenceRect = self.superview.frame;
imageInfo.referenceView = self.superview;
// Setup view controller
JTSImageViewController *imageViewer = [[JTSImageViewController alloc]
initWithImageInfo:imageInfo
mode:JTSImageViewControllerMode_Image
backgroundStyle:JTSImageViewControllerBackgroundOption_Scaled];
// Present the view controller.
[imageViewer showFromViewController:self transition:JTSImageViewControllerTransition_FromOriginalPosition];
imageViewer = nil;
}
The showFromViewController line crashes. showFromViewController行崩溃了。
Advice? 建议吗?
Your tableviewcell seems to be the collectionviews delegate/data source. 您的tableviewcell似乎是collectviews委托/数据源。 This is generally not a good idea, so everytime you nest table/collectionviews inside cells the viewcontroller managing the outer collection should be the delegate/datasource for both.
这通常不是一个好主意,所以每次在table中嵌入table / collectionviews时,管理外部集合的viewcontroller应该是两者的委托/数据源。 This way your viewcontroller implements the didSelectItemAtIndexPath and can present another VC
这样,您的viewcontroller实现了didSelectItemAtIndexPath,并且可以呈现另一个VC
您可以在tableViewCell中添加CollectionViewController而不是CollectionView,这样您就可以呈现模态,并且您的单元格不会直接处理数据源/委托。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.