Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

When is layoutsubviews called in the uiscrollview?


Asked by Armando Galindo on Dec 13, 2021 FAQ



Note specifically that is why layoutSubviews: is called whenever a UIScrollView scrolls, as it performs the scrolling by changing its bounds' origin. Changing the frame will only change the bounds if the size has changed, as this is the only thing propagated to the bounds property.
Besides,
A change in bounds of a view that is not yet in a view hierarchy will result in a call to layoutSubviews: when the view is eventually added to a view hierarchy. And just for completeness: these triggers do not directly call layoutSubviews, but rather call setNeedsLayout, which sets/raises a flag.
Indeed, If it has no autoresize mask then layoutSubview will be called only when the view's (target View) frame size changes. Example: if you created UIView programmatically (it has no autoresize mask by default), LayoutSubview will be called only when UIView frame changes not on every addSubview.
Subsequently,
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.
Also Know,
Its own bounds (not frame) changed. The bounds of one of its direct subviews changed. A subview is added to the view or removed from the view. The bounds are considered changed only if the new value is different, including a different origin.