我的“库”样式UIViewController以1.75弧度的角度执行CATransform3D旋转动画,以便在推动(没有动画)到下一个或最后一个视图之前隐藏它。不幸的是,在弹出UIViewController时执行动画时,弹出的VC不会响应触摸。
我尝试过的事情: -
我当前的代码,虽然有点凌乱(我第一次使用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弧度,因此将保持在该变换角度,直到它旋转回来。
我的代码的任何提示也将不胜感激!
答案 0 :(得分:1)
经过3天的调试后,我找到了答案。原来我最好使用以下行来刷新整个ViewController。内存很重,但它修复了一个巨大的错误。
[self becomeFirstResponder];