3

私の「ライブラリ」スタイルのUIViewControllerは、1.75ラジアンの角度でCATransform3D回転アニメーションを実行し、次のビューまたは最後のビューにプッシュする前に(アニメーションなしで)非表示にします。残念ながら、UIViewControllerのポップでアニメーションを実行すると、ポップされたVCはタッチに応答しません。

私が試したこと:-

  • ポップ後にアニメーションを表示するには、アニメーションをまったくアニメーション化しないのではなく、0.1秒遅らせる必要があります。これを行うには、NSObjectのperformSelector:withObject:afterDelayを使用します。残念ながら、これは完全に意図されたアニメーションを実行している間、私の名前の問題を引き起こします。
  • NSTimerを使用して、0.1秒後に繰り返しなしでアクションを実行します。これは何もしません。
  • アニメーション中にUIViewの遅延機能を使用するため。これは、アニメーションが実行されないことを意味します。
  • セレクターを使用して、別の人から参照されてアニメーションを実行すること。効果はありません。
  • ビューがタッチに応答していないときにtouchesEndedを呼び出すには、効果はありません。

私の現在のコードは、少し乱雑ですが(Core Animation / QuartzCoreの最初の使用)、...

ポップされた場合にアニメーションを実行します。

//To collect it in the SecondVC
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(coolAnimation) name:@"ReturnSecond" object:nil];
//To send it from the ThirdVC
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReturnSecond" object:nil];

VCをポップするには

[[NSNotificationCenter defaultCenter] postNotificationName:@"ReturnWeird" object:nil];
NSUInteger integer = [[self.navigationController viewControllers] indexOfObject:self];
[[self navigationController] popToViewController:[[self.navigationController viewControllers] objectAtIndex:integer-1] animated:NO];

アニメーションを提示するには

- (void)coolAnimation
{
    [self performSelector:@selector(tryThis) withObject:nil afterDelay:0.1];
}

- (void)tryThis
{
    CGRect framer = self.view.layer.frame;
    self.view.layer.anchorPoint = CGPointMake(0.f, 0.f);
    self.view.layer.frame = framer;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
    CATransform3D rotationAndPerspectiveTransforms = CATransform3DIdentity;
    rotationAndPerspectiveTransforms.m34 = 1.0 / 500;
    rotationAndPerspectiveTransforms = CATransform3DRotate(rotationAndPerspectiveTransforms, 0, 0, 1, 0);
    self.view.layer.transform = rotationAndPerspectiveTransforms;
    [UIView commitAnimations];

    CGRect framers = flippedCell.layer.frame;
    flippedCell.layer.anchorPoint = CGPointMake(0.f, 0.f);
    flippedCell.layer.frame = framers;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.7];
    CATransform3D rotateTransform = CATransform3DIdentity;
    rotateTransform.m34 = 1.0 / 500;
    rotateTransform = CATransform3DRotate(rotateTransform, 0, 0, 1, 0);
    flippedCell.layer.transform = rotateTransform;
    [UIView commitAnimations];

    [self performSelector:@selector(cellAnimationDidStop) withObject:nil afterDelay:0.7];
}

- (void)cellAnimationDidStop
{
    [self.tableView reloadData];
}

ビューは押す前に1.75ラジアン回転するため、後ろに回転するまでその変換角度で保持されます。

私のコードのヒントもいただければ幸いです。

4

1 に答える 1

1

3日間のデバッグの後、答えが見つかりました。ViewController 全体を更新するには、次の行を使用するのが最善であることがわかりました。メモリは重いですが、大きなバグが修正されています。

[self becomeFirstResponder];
于 2012-12-19T21:31:20.977 に答える