Abdullah Shafique
Abdullah Shafique

Reputation: 6918

Warnings: Misplaced View

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?

Upvotes: 49

Views: 28369

Answers (6)

Ralf
Ralf

Reputation: 1108

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.

Upvotes: 4

Josh at The Nerdery
Josh at The Nerdery

Reputation: 1397

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

Upvotes: 79

Joseph Astrahan
Joseph Astrahan

Reputation: 9082

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

Upvotes: 3

arcady bob
arcady bob

Reputation: 1574

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.

Upvotes: 3

Ben
Ben

Reputation: 969

To be more specific, Select your view, Go to Editor Menu -> from Resolve Auto Layout Issues select 'Clear Constraints'. This should clear your constraints and no longer give you warning when you move your components.

Upvotes: 0

folse
folse

Reputation: 1801

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

It works for me.

Upvotes: 24

Related Questions