0

漫画アプリのレイアウトエディタを作っています。漫画本のページは行に分割され、各行には少なくとも 1 つの列があります。ユーザーが列を縦方向にスワイプすると、2 つの列に分割されるはずです。この部分はすでに正常に動作していますが、+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];
                }];

}

すべてのビューのジオメトリを既に確認しましたが、問題ないようです。また、完了ブロックは適切に実行されます。

何が問題なのですか?

4

1 に答える 1

0

でビューをアニメーション化することにも行き詰まりましたtransitionWithView

プロジェクトの階層はわかりませんが、これでアニメーション化するビュー用に別のクラスを作成できる場合は、簡単です。

[UIView transitionWithView:self.view duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{} completion:^(BOOL f){}];

動作します..つまり、この関数は で適切に動作しself.viewます。

お役に立てば幸いです。

于 2011-09-02T11:13:06.993 に答える