![](/img/trans.png)
[英]Swift - how to open another viewcontroller with CollectionViewCell inside UITableViewCell
[英]How to show view controller when clicking on CollectionViewCell INSIDE a UITableViewCell
我有一個自定義UITableViewCell,它有一個帶有許多collectionViewCells的CollectionView。
單擊每個CollectionViewCell時Xcode崩潰。
這些代碼位於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;
}
showFromViewController行崩潰了。
建議嗎?
您的tableviewcell似乎是collectviews委托/數據源。 這通常不是一個好主意,所以每次在table中嵌入table / collectionviews時,管理外部集合的viewcontroller應該是兩者的委托/數據源。 這樣,您的viewcontroller實現了didSelectItemAtIndexPath,並且可以呈現另一個VC
您可以在tableViewCell中添加CollectionViewController而不是CollectionView,這樣您就可以呈現模態,並且您的單元格不會直接處理數據源/委托。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.