【发布时间】:2014-08-31 20:24:39
【问题描述】:
我已经将我的 collectionViewCell 中的 push segue 连接到情节提要中的 viewController,但是当单击单元格时没有任何反应。我该怎么做才能做到这一点?
prepareForSegue
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqual:@"toHomeProfile"])
{
HomeProfileViewController * dvc = segue.destinationViewController;
self.selectedIndexPath = [[self.collectionView indexPathsForSelectedItems] firstObject];
dvc.imageArray = [[NSMutableArray alloc]init];
dvc.imageArray = [imageDic objectAtIndex:self.selectedIndexPath.item];
}
}
viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
CHTCollectionViewWaterfallLayout *layout = [[CHTCollectionViewWaterfallLayout alloc] init];
layout.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
layout.headerHeight = 0;
layout.footerHeight = 0;
layout.minimumColumnSpacing = 5;
layout.minimumInteritemSpacing = 5;
self.collectionView.collectionViewLayout = layout;
_collectionView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_collectionView.dataSource = self;
_collectionView.delegate = self;
_collectionView.backgroundColor = [UIColor whiteColor];
[_collectionView registerClass:[CHTCollectionViewWaterfallCell class]
forCellWithReuseIdentifier:CELL_IDENTIFIER];
}
【问题讨论】:
-
你不应该做任何事情。如果转场是由单元格制作的,则不需要任何代码来执行转场。只需确保您的调用是可点击的——例如,如果它有一个图像视图,请确保将其 userInteractionEnabled 设置为 YES(图像视图默认为 NO)。
标签: ios objective-c iphone uicollectionview