【发布时间】:2015-10-07 13:26:02
【问题描述】:
我正在使集合视图单元格翻转并提供有关单元格的信息。
故事板:
-Collectionviewcell
-- View1 (tag 100)
-- View2 (tag 200)
didSelectItemAtIndexPath上的代码。
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
UIView *firstView = (UIView *)[cell viewWithTag:200];
UIView *secondView = (UIView *)[cell viewWithTag:100];
NSString *indexValue = [flipIndex objectAtIndex:indexPath.row];
if (![indexValue isEqualToString:@"1"])
{
[UIView animateWithDuration:1.0 animations:^{
NSLog(@"ANIMATION STARTED");
[UIView transitionFromView:secondView
toView:firstView
duration:2.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
[firstView setHidden:NO];
[secondView setHidden:YES];
}];
}completion:^(BOOL finished) {
NSLog(@"ANIMATION COMPLETED");
}];
[flipIndex removeObjectAtIndex:indexPath.row];
[flipIndex insertObject:@"1" atIndex:indexPath.row];
} else
{
[UIView animateWithDuration:1.0 animations:^{
NSLog(@"ANIMATION STARTED");
[UIView transitionFromView:firstView
toView:secondView
duration:2.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
[secondView setHidden:NO];
[firstView setHidden:YES];
}];
}completion:^(BOOL finished) {
NSLog(@"ANIMATION COMPLETED");
}];
我在这里面临的问题是,在第一次单击时,视图会从视图 1 翻转到视图 2。在第二次点击视图 2 时,视图 1 是空白的,因为它是 nil。
帮助表示赞赏。
【问题讨论】:
标签: ios uicollectionview