简体   繁体   English

按下后,动画UIView会挂在屏幕上

[英]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.

相关问题 在UIView后面捕获(动画)屏幕 - Capturing (animated) screen behind UIView Swift——当移除 UIView(动画)时,它会停留在屏幕上 - Swift -- When removing UIView (animated) it stays on screen 旋转设备时动画uiview切换回其原始状态 - Animated uiview switches back to its original state when rotating device 按下返回按钮后,UIWebView仍处于活动状态 - UIWebView still active after pressing back button 按下返回按钮后,navigationController为NULL - navigationController is NULL after pressing the back button 一段时间后,所有UIView动画/过渡都无法进行动画处理? - All UIView animation / transitions becoming non-animated after a while? Obj-C-在对UIView进行动画处理后,UITapGestureRecognizer无法正常工作吗? - Obj-C - UITapGestureRecognizer doesn't work after UIView is animated? 在UIViews图层动画化后,UIView上的UIPanGestureRecognizer表现得很奇怪 - UIPanGestureRecognizer on a UIView behaves oddly after UIViews layer is animated iOS 科尔多瓦应用程序在闪屏后挂起 - iOS cordova app hangs after splash screen Swift-屏幕更新后-UIView到UIImage的转换 - Swift - After Screen Updates - UIView to UIImage Conversion
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM