子视图在翻转过渡期间不显示 [英] Subviews not displaying during Flip Transition

查看:102
本文介绍了子视图在翻转过渡期间不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在容器视图的两个子视图之间进行翻转转换.容器视图不是全屏视图,也不是视图控制器的根视图(它是其子视图,大约占据屏幕的底部三分之一).

I am doing a flip transition between two subviews of a container view. The container view is NOT fullscreen and is not the root view of the view controller (it is a subview thereof, taking roughly the bottom third of the screen).

在翻转转换中切换的两个子视图(均为UIImageView)中,其中一个又有两个子视图(同样为UIImageView类型).此子视图是由于过渡而消失"的子视图.

Of the two child views being switched in the flip transition (both of them UIImageView), one of them has two children in turn (again, of UIImageView type). This subview is the one that "goes away" as a result of the transition.

过渡开始后,退出的UIImageView实例会翻转,但是它的两个子对象会立即消失.在后半段,进入的UIImageView实例显示没有问题(它没有子对象).

As soon as the transition starts, the exiting UIImageView instance flips allright, but its two children disappear immediately. During the second half, the entering UIImageView instance appears with no problems (it has no children).

我尝试使包含视图全屏显示和不透明,没有任何效果.我读到有关contentMode,contentStretch和自动调整大小的蒙版,但事实并非如此.

I have tried making the containing view fullscreen and opaque, to no effect. I read about contentMode, contentStretch and autoresizing masks but doesn't seem to be it.

我正在使用老式动画块.我尝试在块内设置进入/退出子视图的hidden属性,然后在块内添加/删除子视图,但是结果是相同的.我什至尝试使用现代语法,Objective-C代码块,但仍然没有任何变化.

I am using an old-style animation block. I tried setting the hidden property of the entering/exiting subviews inside the block, and adding/removing them inside the block, but the result is the same. I even tried using modern-syntax, Objective-C code blocks but still no change.

推荐答案

我找到了答案:在动画块开始之前添加了子级(与动画块相同的方法内,几行之前).

I found the answer: the children were being added just before the animation block begins (inside the same method as the animation block, few lines before ).

我测试了较早添加其他子级(例如,在-viewDidLoad处),并且在动画过程中保留了这些子级.

I tested adding other children earlier on (say, at -viewDidLoad) and those stay during the animation.

我的猜测是,更改视图层次结构会超出单行"addSubview:"之外的一些异步处理,而新的子代并没有及时成为动画的一部分.动画块本身是异步的,但是一定要在提交时固定某些东西(例如,视图层次结构).

My guess is, changing the view hierarchy encompasses some asynchronous precessing beyond the one-line "addSubview:", and the new children didn't make it in time to be part of the animation. The animation block itself is asynchronous but a certain amount of things must certainly be fixed by the time you commit it (e.g., the view hierarchy structure).

这篇关于子视图在翻转过渡期间不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆