Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 5 layout errors - Misplaced View Frame for Label will be different at runtime

I just installed Xcode 5 and I am currently preparing my apps for release to the App Store on iOS 7 next week. I am getting a whole bunch of errors and warnings though.

In one app where I have a UIPickerView, UITextFields and a bunch of UILabels. In this app it gives an Illegal Configuration (red) error on almost all controls in the storyboard file. I don't know what that error is or how to fix it. I would appreciate some help on that. I can't completely recreate the file because there are 20 complicated views.

In another app there is a UIScrollView containing a bunch of UILabels and UITextFields, plus one UITextView that is created programmatically and contains text based on what you selected in a (previous view) UITableView as well as resizing itself to fit the content. The UIScrollView resizes to accommodate for the new size of the UITextView. This one compiles and builds and the UITextView gets created but doesn't contain the text, probably because it now resizes incorrectly. The UIScrollView now also scrolls horizontally in addition to vertically which it isn't supposed to. This one gives only (yellow) warnings which all say:

Misplaced View Frame for "Label - Symbol:" will be different at run time. for 4 controls including this Label and another, a Text Field and the Scroll View.

I would appreciate any help on this because this is the first time for me adjusting to a new version of Xcode and iOS.

P.S: Details on the Illegal Configuration error include:
Auto Layout on iOS Versions prior to 6.0

Thanks!

like image 586
Youssef Moawad Avatar asked Sep 11 '13 11:09

Youssef Moawad


4 Answers

If you're still looking for an answer here, the answer is likely that you have either no constraints, or improper constraints, on your AutoLayout view.

You can fix this by selecting the view and going to the Xcode menu option: Editor -> Resolve Auto Layout Issues -> Add Missing Constraints / Reset to Suggested Constraints.

You can also select the entire layout and do the same thing, this will reset all of the views on your layout to recommended constraints.

If you need to do custom constraints, you will have to set up your own auto layout constraints either in the Storyboard/XIB file, or manually in code.

For more information about Auto Layout, you can see Apple's documentation.

Finally, you can also turn off auto layout on the layout if you want it to appear as-is, with no automatic readjustments (this is not recommended).

enter image description here

like image 59
Joel Fischer Avatar answered Oct 24 '22 20:10

Joel Fischer


Reset to Suggested Constraints sometimes does not get rid of this warning. The solution is to select Placeholder in the Intrinsic Size drop down menu in the Size inspector of the UIView in question. And then add the missing constraints as needed.

like image 42
Morrowless Avatar answered Oct 24 '22 20:10

Morrowless


Simply select your view controller Go to

Editor-->Resolve Autolayout issues--> Clear All Constraints in ViewController and you are done.

like image 37
ProgrammingNinja Avatar answered Oct 24 '22 21:10

ProgrammingNinja


Regarding Frame "Label frame will be different at run time" -- Please see the release notes under Autolayout: Runtime.

https://developer.apple.com/library/prerelease/ios/releasenotes/DeveloperTools/RN-Xcode/index.html#//apple_ref/doc/uid/TP40001051

Full answer will be shown here after the NDA is lifted.

Note: this also happens under Xcode 4.2 as well, but the problem isn't surfaced by IB.

like image 36
memmons Avatar answered Oct 24 '22 20:10

memmons