ViewController sub view frame.width is always 0 in viewDidLoad

In any view controller sub view that is created on the storyboard, its frame data is 0,0,0,0 on viewDidLoad. I don't think this is the case in the live production xcode/iOS.


For example dragging a button onto a view controller in a storyboard, setting its width and height to 50,50... in viewDidLayout, buttonView.frame.width and buttonView.frame.height are both 0.


The view renders fine, however I cannot use those values in code, which is problematic


Is anyone else experiencing this in xCode 10 beta 3?

Regardless of OS version you can't ever expect valid frame values in viewDidLoad. The view may not yet be added to a window or the view hierarchy. Even if you get a nonzero frame, that will be the frame size as it came from the storyboard, not the final size it will be once layout is performed. You have to do any layout related calculations in viewDidLayoutSubviews after layout.

ViewController sub view frame.width is always 0 in viewDidLoad
 
 
Q