我正在为漫画书应用程序制作布局编辑器。漫画书的页面被分成几行,然后每行至少有一列。当用户在列上执行垂直滑动时,它应该分成两个单独的列。这部分已经可以正常工作了,但我想使用 +transitionWithView: 添加一个简单的卷曲过渡。一切仍然正常(列很好地划分),但没有动画。这是代码:
- (void)divideColumnView:(CCLayoutColumnView *)columnView atPoint:(CGPoint)_divisionPoint {
// divides a single column into two smaller ones
// define frames for new columns
CGRect frameLeft = columnView.frame;
CGRect frameRight = frameLeft;
CGFloat width = _divisionPoint.x - frameLeft.origin.x;
frameLeft.size.width = width;
frameRight.size.width -= width;
frameRight.origin.x += width;
// set up the container for transition
UIView *rowView = [columnView superview];
UIView *containerView = [[UIView alloc] initWithFrame:columnView.frame];
[rowView addSubview:containerView];
// move the column to the container
columnView.frame = [containerView convertRect:columnView.frame fromView:rowView];
[containerView addSubview:columnView];
// set up columns that will be inserted to the container during transition
CCLayoutColumnView *leftColumnView = [[CCLayoutColumnView alloc] initWithFrame:[containerView convertRect:frameLeft fromView:rowView]];
CCLayoutColumnView *rightColumnView = [[CCLayoutColumnView alloc] initWithFrame:[containerView convertRect:frameRight fromView:rowView]];
[UIView transitionWithView:containerView
duration:0.5
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
[columnView removeFromSuperview];
[containerView addSubview:leftColumnView];
[containerView addSubview:rightColumnView];
}
completion:^(BOOL finished){
// add columns to their row
leftColumnView.frame = frameLeft;
rightColumnView.frame = frameRight;
[rowView addSubview:leftColumnView];
[rowView addSubview:rightColumnView];
// clean up
[containerView removeFromSuperview];
[containerView release];
[leftColumnView release];
[rightColumnView release];
}];
}
我已经检查了所有视图的几何形状,看起来还可以。此外,完成块被正确执行。
可能是什么问题?