bpedit bpedit - 3 months ago 6
Swift Question

timing of constraints application

I have a

in which I display a movie if a particular chapter demands it. This view is resized via constraints in
to adapt to iPhone. All works fine on iPad. It also works fine on iPhone unless the app is asked to reload when a movie containing chapter was last active meaning that a movie will be first-up on loading. In this scenario, the movie is loaded into the iPad dimensions instead of the smaller iPhone specs.

It appears that the constraints on the movie's view are not engaged in a timely manner. The issue centers on a query of the the view's bounds. If I insert a delay before using the bounds the issue goes away. In fact, a delay of 0.0 seconds does the job!

Using a kludge that relies on a delay seems pretty funky to me. I can also move the call that uses the bounds to
to resolve the issue but then I see some underlying “garbage” when reloading the app, the launch image seemingly not in effect. Any suggestions?


It sounds like you're using bounds before your views have been lain out. Without actually seeing your code, I would suggest executing your described code inside of viewDidLayoutSubViews().