自动布局不iOS8上-X $ C $ 6即时更新帧 [英] Autolayout is not updating frames instantly in iOS8-Xcode6

查看:125
本文介绍了自动布局不iOS8上-X $ C $ 6即时更新帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用自动布局 X $ C $ 6

我已经申请了以下限制到滚动视图

I have applied the following constraints to a scrollview.

我试图访​​问帧此滚动型的 - viewDidLoad中和 - viewWillAppear中的iPhone 4Inchs设备方法。这里的问题是,滚动视图的宽度显示登录600。但是当我用我自动布局的宽度应该是300 4Ichs设备。
好像自动布局将一定的时间间隔后适用。它显示正确的宽度 - viewDidAppear 方法30​​0

I have tried to access the frame of this scrollview in -viewDidLoad and -viewWillAppear methods for iPhone 4Inchs device. Here problem is, the scrollview's width is showing 600 in Log. But the width should be 300 in 4Ichs device as i'm using autolayout. Seems autolayout will apply after some time interval. It is showing correct width in -viewDidAppear method as 300.

有什么办法来访问原始帧 - viewDidLoad中和 - viewWillAppear中方法

Is there any way to access the original frames in -viewDidLoad and -viewWillAppear methods ?

先谢谢了。

推荐答案

自动布局不给你正确的帧大小,直到布局传递发生。 viewDidLoad中是得太早了,把我的头顶部的 willAppear 可能太。 viewDidLayoutSubviews 是正确的地方。

Auto layout doesn't give you the "right" frame sizes until a layout pass has happened. viewDidLoad is too early, and off the top of my head willAppear might be too. viewDidLayoutSubviews is the right place.

这篇关于自动布局不iOS8上-X $ C $ 6即时更新帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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