"API error: (null) 0 width returned, assuming UIViewNoIntrinsicMetric" in Xcode 9 beta
@rmaddy is correctly linked from another SO answer, however there are other possibilities related to auto-layout methods.
The message can also be related to auto-layout implementations and unique constraints defined in your project. It seems that this message does not usually appear when using a real device.
UIKit framework -> UIView API Global Variable UIViewNoIntrinsicMetric
UIViewNoIntrinsicMetric
No built-in metric for a given numeric property.
UIView Implementation Practice
Each UIView subclass must implement intrinsicContentSize and return a size that it thinks is appropriate for it. For example:
- If you know the width of the UIView, you use return CGSizeMake (200, 50).
- If you don't know how wide the view is, you should use
UIViewNoIntrinsicMetric
instead of width.return CGSizeMake(UIViewNoIntrinsicMetric, 50)
The UIView database implementation updateConstraints
will call intrinsicContentSize and use the content size returned from it to add constraints to the UIView.
UIView API Property intrinsicContentSize
intrinsicContentSize
The natural size for the receiving view, considering only the properties of the view itself.
Custom views typically contain content rendered on the screen that the layout system is not aware of. Setting this property allows the custom view to communicate with the layout system what size it would like to use on its content. This intrinsic size should be independent of the content frame because there is no way to dynamically link the resized width to a layout based on the resized height, for example. If the custom view does not have its own dimension for a given dimension, it can use
UIViewNoIntrinsicMetric
that dimension.
Conclusion
Xcode error:
returns 0 width, assuming UIViewNoIntrinsicMetric
Therefore, we can get an idea of ββXcode taking a UIViewNoIntrinsicMetric value since a width size of 0 was returned by some UIView in your project.
If you still get the message when deploying to a real device, I give extra attention to your layout constraints.
source to share