[英]Animated UIView hangs on screen after pressing back
I can't figure out what's happening here. 我不知道这里发生了什么。 I have two views on screen that serve as a "gate" until the camera is ready to record. 屏幕上有两个视图,它们充当“门”,直到照相机准备好进行记录为止。 Afterwards they slide out. 之后,他们滑出。 It works, i'm happy, and that's great. 它很有效,我很高兴,那太好了。 The problem is regardless of when I choose to go "back" on the navigation controllers back option (be that during the animation or after it finishes) the left view "sticks out" on the view controller i'm going back to. 问题是无论我何时选择在导航控制器的“后退”选项上“返回”(无论是在动画过程中还是在动画完成后),我要返回的视图控制器上的左视图都“伸出”。
I've tried removing all animations -and- removing the views from the superview when the ViewWillDisappear method... but no luck, this view persistently sticks out on the home page when I click back from the recording page. 我尝试过删除所有动画,并且在使用ViewWillDisappear方法时从超级视图中删除了视图...但是没有运气,当我从录制页面上单击时,该视图会一直出现在主页上。
-(void)animateViewsOut
{
[UIView animateKeyframesWithDuration:1 delay:0 options:UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionCurveEaseIn animations:^{
_leftView.layer.transform = CATransform3DMakeTranslation(-_leftView.frame.size.width, 0.0, 0.0);
_rightView.layer.transform = CATransform3DMakeTranslation(_rightView.frame.size.width, 0.0, 0.0);
} completion:^(BOOL finished) {
[_leftView removeFromSuperview];
[_rightView removeFromSuperview];
}];
}
and my attempt to solve the problem 和我解决问题的尝试
- (void) viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[_leftView.layer removeAllAnimations];
[_rightView.layer removeAllAnimations];
[_leftView removeFromSuperview];
[_rightView removeFromSuperview];
[[CameraEngine engine] shutdown];
}
So, as it turns out the problem's root was due to me inserting the views on the view controllers main view 因此,事实证明,问题的根源是由于我在视图控制器主视图上插入了视图
[self.view addsubview:_leftView];
[self.view addsubview:_rightView];
I instead created a container for the views that I built onto the storyboard, then added the the views as subviews of that overview, and kept the same animation, except on completion instead of removing the views individually, I just remove the overlay container instead (change in the code below). 我改为为构建在情节提要板上的视图创建一个容器,然后将视图添加为该概述的子视图,并保留相同的动画,只是在完成时(而不是单独删除视图),我只是删除了覆盖容器(更改下面的代码)。
-(void)animateViewsOut
{
[UIView animateKeyframesWithDuration:1 delay:0 options:UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionCurveEaseIn animations:^{
_leftView.layer.transform = CATransform3DMakeTranslation(-_leftView.frame.size.width, 0.0, 0.0);
_rightView.layer.transform = CATransform3DMakeTranslation(_rightView.frame.size.width, 0.0, 0.0);
} completion:^(BOOL finished) {
[_overlayView removeFromSuperview];
}];
}
After I made this change, the views didn't persist when tapping back in the navigation controller. 进行此更改后,在导航控制器中单击时,视图不会保留。
I removed all of the code from the viewWillDisappear method, removing the overlay container after the animation completed solved the problem on its own. 我从viewWillDisappear方法中删除了所有代码,并在动画完成后自行解决了问题,然后删除了覆盖容器。
- (void) viewWillDisappear:(BOOL)animated {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.