Warning:automatic preferred Max Layout Width before IOS 8.0

Source: Internet
Author: User

Solution Address: http://stackoverflow.com/questions/25398312/ Automatic-preferred-max-layout-width-is-not-available-on-ios-versions-prior-to-8


Here's an excerpt of a few good answers to the solution

Update 3:
This warning can also being triggered by labels that have numberoflines set to anything but 1 if your deployment target is SE T to 7.1. This is completely reproducible with new Single-view project.

Steps to reproduce:create a new Single-view, OBJECTIVE-C project Set the deployment Target to 7.1 Open the project ' s STO Ryboard Drop a label onto the provided view controller Set the NumberOfLines for this label to 2. Compile

I ' ve filed the following radar:
rdar://problem/18700567

Update 2:
Unfortunately, this is a thing again in the release version of Xcode 6. Note This can, for the most part, manually edit your storyboard/xib to fix the problem. Per Charles A. In the comments below:

It's worth mentioning can pretty easily accidentally introduce this warning, and the warning itself ' t help In finding the label this is the culprit. This is unfortunate in a complex storyboard. You can open the storyboard as a source file and search with the regex <label (?!. *preferredmaxlayoutwidth) to find labels that omit a preferredmaxlayoutwidth attribute/value. If you add in preferredmaxlayoutwidth= ' 0 ' on such lines, it is the same as marking explicit and setting the value 0.

Update 1:
This bug is has now been the fixed in Xcode 6 GM.

Original Answer
This is a bug in Xcode6-beta6 and Xcode6-beta7 and can safely ignored to now.

An Apple engineer in the Apple Developer forums had this to say about the bug:

Preferred Max layout width is a auto layout property on Uilabel This allows it to automatically grow to fit it S content. Versions of Xcode prior to 6.0 would set preferredmaxlayoutwidth for multiline labels to the current bounds size at Time. You are would need to manually update preferredmaxlayoutwidth at runtime if your horizontal layout.

IOS 8 added support for automatically computing preferredmaxlayoutwidth at runtime, which makes creating multiline Even easier. This setting isn't backwards compatible with IOS 7. To support both iOS 7 and iOS 8, Xcode 6 allows with pick either "Automatic" or "Explicit" for Preferredmaxlayoutwidth I n the size inspector. You should:

Pick "Automatic" if targeting IOS 8 for the best experience. Pick "Explicit" if targeting < IOS 8. You can then enter the value of Preferredmaxlayoutwidth your would like set. Enabling "Explicit" defaults to the current bounds size in the time for you checked the box.

The warning would appear if (1) you ' re using auto layout, (2) "Automatic" are set for a multiline label [with can check this In the size inspector for the label], and (3) your deployment target < IOS 8.

It seems the bug is, this, warning appears for non-autolayout documents. If you are are seeing this warning and not using auto layout you can ignore the warning.

Alternately, you can work around the issue by using the file inspector on the storyboard or xib in question and change "Bu Ilds for ' to ' builds for IOS 8.0 and later

[  
It's worth mentioning that can pretty easily accidentally introduce this warning, and the warning itself doe SN ' t help in finding the label this is the culprit. This is unfortunate in a complex storyboard. You can open the storyboard as a source file and search with the Regex <label (?!. *preferredmaxlayoutwidth)  to Find labels that omit a preferredmaxlayoutwidth attribute/value. If you add in preferredmaxlayoutwidth= ' 0 '  on such lines, it is the same as marking explicit and setting e 0.–  Charles a.  Oct at 1:31 
6
Are there any way programatically to configure a Uilabel to automatically adjust, preferredmaxlayoutwidth without Subclassing it or implementing it somewhere in Layoutsubviews? If It is a behavior so IB can enable, that's suggests there ' a property or magic value of can be set. But the API docs or headers says that. –algal Oct at 23:32
1
@CharlesA.  I ' ve been testing with a empty project and found another label attribute that would trigger this warning:if NumberOfLines is set to anything but 1, the warning would happen regardless of if you have preferredmaxlayoutwidth set or not. –memmons Oct at 15:44
2
@MichaelG. Emmons Strange, I cannot reproduce this with a clean project and a deployment target set to 7.1. Once I Set the preferredmaxlayoutwidth to a explicit 0 the warning goes away of the regardless value. But Perhaps this is fixed in the Xcode update this morning?  –charles A. OCT at 18:01
2
So ... is the "only" solution to set the number of lines to 1 and change it from code? This doesn ' t seem professional–jomafer Dec 4 ' at 10:29


To find the problem label (s) in a large storyboard, follow my steps below. In XCode ' s Issue Navigator right click on the error and select "Reveal in Log". (Note: The @Sam suggests below, look in XCode ' s navigator. Also @Rivera notes in the ' comments that ' as of Xcode 6.1.1, clicking on the warning would automatically open and highlight The conflicting label ". I Haven ' t tested this).

This'll show the error with a code in the end of your storyboard file. Copy the value after. Storyboard

Next, reveal your storyboard as source file.

Search. You are able to tell what label it are from should quite easily by looking at the content.

Once you find the label the ' solution ' worked for me is to set the ' preferred width ' to 0.

BTW, you can always quickly get the ID of a interface item by selecting the item and looking under the Identify Inspector . Very Handy.


34
This should is the accepted answer! This actually solves the problem. It even helps find issues in the Storyboard which don ' t show up normally. One thing:i find that the the "the" Navigator are much reliable than right-clicking to the "Reveal in Log" –sam 1 9 ' at 3:13
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.