Warnings: Misplaced View

27,711

Solution 1

In Xcode 5 the position of views on the canvas does not update when constraints are applied. Thus, it is possible to have constraints that specify a different position for the view than you see it in Interface Builder. You can correct this by pressing Command + Option + = or selecting "Update Frames" in the |-•-| menu (I think it looks like a tie fighter).

Update for Xcode 8: The "Update Frames" command now has its own button. It's located just to the left of the Stack View / Alignment / Constraints buttons and looks like a reload arrow surrounded by corner brackets:

Update Frames

Solution 2

Select this view in Storyboard, then 'Editor -> Resolve Auto-Layout Issues -> Update All Constraints in View'

It works for me.

Solution 3

Xcode 8: I got this warning with 1 UICollectionView in the Storyboard and no constraints at all. Switching the "View as"-Device at the bottom to any other device and back removes the warning.

Solution 4

In Xcode 8.1 there is now a refresh button to the far left, click your views and click that to be the equivalent of the old update frames.

enter image description here

Solution 5

In XCode 6 the Warning is now accompanied with dimensions indicating where the view will be placed given the current constraints. If your constraints are correct (or you believe them to be) and the view (eg. a label) is not at that location, try changing the view's dimensions to the expected dimensions in the warning. If the view ends up in the right place and the warning goes away, it confirms that your constraints are working as expected.

Simply removing the constraints may remove the warning but won't necessarily give you the Auto Layout behavior you are hoping for.

Share:
27,711

Related videos on Youtube

Abdullah Shafique
Author by

Abdullah Shafique

Updated on July 09, 2022

Comments

  • Abdullah Shafique
    Abdullah Shafique almost 2 years

    I recently updated Xcode and I got the following warnings:

    enter image description here

    I tried Editor -> Resolve Auto-Layout Issues -> Clear all constraints in view controller but it did not work... I am using Xcode 5. How do I remove the warnings?

  • Josh at The Nerdery
    Josh at The Nerdery over 10 years
    If a view has no constraints, I'm not sure what the behavior will be. You can try using "Add recommended constraints..." in the dot menu as a starting point.
  • Nick
    Nick over 10 years
    I had it only work for some of the warnings too, but the others were cleared when I rebuilt the app. Won't work all the time but worth a try.
  • Mathijs Segers
    Mathijs Segers about 9 years
    This just jinxes my layout, the, update constraints actually does help me get rid of the warning.
  • Island Wave
    Island Wave about 9 years
    This article is helpful for resolving constraint and view misplacement issues in XCode 6 as arcady bob mentioned above : developer.apple.com/library/ios/documentation/UserExperience‌​/…
  • Lazy Ninja
    Lazy Ninja over 6 years
    Magic! Worked like a charm!
  • Abhishek
    Abhishek over 6 years
    not working for me. Event I have not applied any constraints. Getting error on xcode 9.
  • Chewie The Chorkie
    Chewie The Chorkie about 6 years
    It gets rid of the warning, but makes my button width and height not equal which is exactly what I'm trying to fix.
  • AnthoPak
    AnthoPak about 6 years
    It works, but the warning comes back later… Did you find any persistent solution ? It seems to be a Xcode bug (using Xcode 9.2)
  • user25
    user25 about 5 years
    It adds constants from canvas to my constraints! But I just want to update position of views in canvas
  • user25
    user25 about 5 years
    So the correct option should be Editor -> Resolve Auto-Layout Issues -> Update Frames
  • user25
    user25 about 5 years
    So be careful users. It should be Update Frames. An accepted answer also mentions it stackoverflow.com/a/18920275/4548520