什么时候调用layoutSubviews? [英] When is layoutSubviews called?

查看:103
本文介绍了什么时候调用layoutSubviews?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义视图,在动画期间不会获得 layoutSubview 消息。

I have a custom view that's not getting layoutSubview messages during animation.

屏幕。它在屏幕底部有一个自定义子视图,在Interface Builder中正确调整大小,如果我更改导航栏的高度。 layoutSubviews 在创建视图时调用,但不会再次调用。我的子视图正确布局。如果我关闭通话状态栏,子视图的 layoutSubviews 根本不会被调用,即使主视图动画了它的调整大小。

I have a view that fills the screen. It has a custom subview at the bottom of the screen that correctly resizes in Interface Builder if I change the height of the nav bar. layoutSubviews is called when the view is created, but never again. My subviews are correctly laid out. If I toggle the in-call status bar off, the subview's layoutSubviews is not called at all, even though the main view does animate its resize.

在什么情况下 layoutSubviews 实际呼叫?

Under what circumstances is layoutSubviews actually called?

我有 autoresizesSubviews 设置为 NO 。在界面生成器中我有顶部和底部的支柱和垂直的箭头设置。

I have autoresizesSubviews set to NO for my custom view. And in Interface Builder I have the top and bottom struts and the vertical arrow set.

推荐答案

坚持在具有打开的模拟屏幕元素的视图(状态栏等)上不能改变弹簧。由于主视图中的弹簧已关闭,所以该视图无法更改大小,因此在通话栏显示时会向下滚动。

I tracked the solution down to Interface Builder's insistence that springs cannot be changed on a view that has the simulated screen elements turned on (status bar, etc.). Since the springs were off for the main view, that view could not change size and hence was scrolled down in its entirety when the in-call bar appeared.

转动模拟功能关闭,然后调整视图和正确设置弹簧导致动画发生和我的方法被调用。

Turning the simulated features off, then resizing the view and setting the springs correctly caused the animation to occur and my method to be called.

调试这是一个额外的问题是,模拟器退出当通过菜单切换通话状态时的应用程序。退出app =无调试器。

An extra problem in debugging this is that the simulator quits the app when the in-call status is toggled via the menu. Quit app = no debugger.

这篇关于什么时候调用layoutSubviews?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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