Ios uicollectionview导航控制器didselectitematindexpath
我正在尝试为我的应用程序创建一个带有UICollectionView的导航站点。当用户单击其中一个单元格时,ViewController应使用单元格图像的缩放动画推送另一个单元格 一切正常,显示下一个视图,但问题是:当我调用下一个视图,然后导航回UICollectionView并再次单击我的单元格时,动画不再显示。 所以我认为ViewController不会调用 -voidcollectionView:UICollectionView*collectionView didSelectItemAtIndexPath:NSIndexPath*indexPath{} 功能消失了,有点记得顺序。但是我该怎么告诉他再做一次动画呢 以下是segue的代码:Ios uicollectionview导航控制器didselectitematindexpath,ios,objective-c,uinavigationcontroller,uicollectionview,uicollectionviewcell,Ios,Objective C,Uinavigationcontroller,Uicollectionview,Uicollectionviewcell,我正在尝试为我的应用程序创建一个带有UICollectionView的导航站点。当用户单击其中一个单元格时,ViewController应使用单元格图像的缩放动画推送另一个单元格 一切正常,显示下一个视图,但问题是:当我调用下一个视图,然后导航回UICollectionView并再次单击我的单元格时,动画不再显示。 所以我认为ViewController不会调用 -voidcollectionView:UICollectionView*collectionView didSelectItemAt
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
CostumCollectionCell *theCell =(CostumCollectionCell*)[self.theCollectionView cellForItemAtIndexPath:indexPath];
UIImageView *overlayer = [[UIImageView alloc]initWithImage:theCell.theImageView.image];
overlayer.frame=theCell.frame;
[overlayer setContentMode:UIViewContentModeScaleAspectFill];
[self.theCollectionView addSubview:overlayer];
[UIView animateWithDuration:0.75 animations:^{
overlayer.frame=CGRectMake(theCell.frame.origin.x-theCell.frame.size.width/2, theCell.frame.origin.y-theCell.frame.size.height/2, theCell.frame.size.width*2, theCell.frame.size.height*2);
} completion:^(BOOL finished) {
switch (indexPath.row) {
case 0:
[self.navigationController pushViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"auditionView"] animated:YES];
[overlayer removeFromSuperview];
break;
default:
break;
}
}];
}
更新代码:
您不必“思考”——您可以在这个方法中设置断点并知道,但是除非您删除了委托,否则这似乎不太可能。就风格而言,你应该看看spring动画——它们是“新”的风格,可能会使用performsguewithidentifier,而不是直接推送新的视图控制器。我根据你的回答做了一些更改。我想我现在不知道他调用了这个方法,只是没有显示动画。编辑:似乎他在第二次通话中得到了零。ODid,你检查了一下电池是否为零?好的,找到了解决方案:我在下一步无意中释放了电池,因为我洗牌了图像。现在可以了。谢谢你们的帮助,伙计们!这些春天的动画是摇滚乐;
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
CostumCollectionCell *theCell =(CostumCollectionCell*)[self.theCollectionView cellForItemAtIndexPath:indexPath];
[self.overlayer setImage:theCell.theImageView.image];
self.overlayer.frame=theCell.frame;
[self.overlayer setHidden:NO];
[UIView animateWithDuration:0.75 delay:0.0 usingSpringWithDamping:0.5 initialSpringVelocity:5.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
self.overlayer.frame=CGRectMake(theCell.frame.origin.x-theCell.frame.size.width/2, theCell.frame.origin.y-theCell.frame.size.height/2, theCell.frame.size.width*2, theCell.frame.size.height*2);
} completion:^(BOOL finished) {
if(finished){
switch (indexPath.row) {
case 0:
[self performSegueWithIdentifier:@"auditionSegue" sender:self];
[self.overlayer setHidden:YES];
break;
default:
break;
}
}
}];
}