自动布局完成后是否会触发 iOS 方法?

Is there an iOS method that fires when Autolayout has completed?(自动布局完成后是否会触发 iOS 方法?)

本文介绍了自动布局完成后是否会触发 iOS 方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 iOS 应用程序,我需要知道新视图何时在屏幕上完全可见;也就是说,当 Autolayout 完成计算并且视图完成绘制时.

I have an iOS app in which I need to know when a new view is completely visible on-screen; that is, when Autolayout has finished its calculations and the view has finished drawing.

ViewDidAppear 似乎在视图完全可见之前就触发了.如果我关闭 Autolayout,时间似乎与人类感知一致,但我需要在这个项目中使用 Autolayout(所以这不是一个解决方案......只是一个测试).

ViewDidAppear seems to fire well before the view is completely visible. If I turn off Autolayout, the timing seems to line up as far as human perception goes, but I need to use Autolayout in this project (so this isn't a solution...just a test).

自动布局计算完成后是否有任何方法可以触发?或者当视图实际可见时触发的另一种方法(因为 ViewDidAppear 不适用于此)?

Is there any method that fires when Autolayout is done calculating? Or another method that fires when the view is ACTUALLY visible (since ViewDidAppear doesn't work for this)?

谢谢!

推荐答案

我正在为此使用 viewDidLayoutSubviews.苹果的文档说,调用通知视图控制器它的视图刚刚布置了它的子视图."

I'm using viewDidLayoutSubviews for this. Apple's documentation says, "Called to notify the view controller that its view has just laid out its subviews."

这篇关于自动布局完成后是否会触发 iOS 方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:自动布局完成后是否会触发 iOS 方法?

基础教程推荐