[英]UIViewController does not respond to touches after CATransform3D Animation
My "Library" style UIViewController performs a CATransform3D rotate animation with an angle of 1.75 Radians, so as to hide it before pushing (with no animation) to the next, or last view. 我的“库”样式UIViewController执行一个角度为1.75 Radians的CATransform3D旋转动画,以便在推动(没有动画)到下一个或最后一个视图之前隐藏它。 Unfortunately, when performing an animation on popping a UIViewController, the popped VC will not respond to touches.
不幸的是,在弹出UIViewController时执行动画时,弹出的VC不会响应触摸。
Things I have tried:- 我尝试过的事情: -
My current code, while a little untidy (my first use of Core Animation/QuartzCore), is... 我当前的代码虽然有点凌乱(我第一次使用Core Animation / QuartzCore),但是......
To perform the animation if popped. 如果弹出则执行动画。
//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];
To pop the VC 弹出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];
To present the animation 呈现动画
- (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];
}
The view is rotated 1.75 radians before pushing and so will be retained at that transform angle until it is rotated back. 在推动之前视图旋转1.75弧度,因此将保持在该变换角度,直到它旋转回来。
Any tips for my code would also be appreciated! 我的代码的任何提示也将不胜感激!
I found the answer after 3 days of debugging. 经过3天的调试,我找到了答案。 Turned out I was best to use the following line to refresh the entire ViewController.
原来我最好使用以下行来刷新整个ViewController。 Memory heavy, but it fixes a huge bug.
内存很重,但它修复了一个巨大的错误。
[self becomeFirstResponder];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.